Setup CodeIgniter
Setup CodeIgniter
This example installs a legacy CodeIgniter 3 application inside Devilbox. For new projects, prefer Setup CodeIgniter4 because CodeIgniter 4 is the actively maintained line.
Overview
| Project name | Container path | Database | TLD_SUFFIX | Project URL |
|---|---|---|---|---|
my-ci | /shared/httpd/my-ci | my_ci | lvh.me | http://my-ci.lvh.me / https://my-ci.lvh.me |
Inside the PHP container, projects are available in /shared/httpd/; on the host they are stored below ./data/www/.
Prerequisites
- Devilbox installed with PHP, HTTPD, MySQL, and Bind available.
- Docker Compose v2 and the
./dvl.shCLI. TLD_SUFFIX=lvh.meor an equivalent local DNS setup.
Start the required services:
./dvl.sh up php httpd mysql bindWalk through
It will be ready in eight steps:
- Enter the PHP container.
- Create a new virtual host directory.
- Download CodeIgniter 3.
- Link the document root.
- Add a MySQL database.
- Configure the database connection.
- Verify DNS.
- Open the project in a browser.
1. Enter the PHP container
./dvl.sh shell php832. Create the vhost directory
mkdir -p /shared/httpd/my-cicd /shared/httpd/my-ci3. Download CodeIgniter
wget https://github.com/bcit-ci/CodeIgniter/archive/3.1.13.tar.gztar xfz 3.1.13.tar.gzExpected structure:
tree -L 1.├── 3.1.13.tar.gz└── CodeIgniter-3.1.134. Link the document root
CodeIgniter 3 keeps index.php in the project root, so link the extracted directory to htdocs:
ln -s CodeIgniter-3.1.13 htdocs5. Add the MySQL database
mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE my_ci CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'6. Configure the database connection
Edit htdocs/application/config/database.php:
$db['default'] = array( 'hostname' => '127.0.0.1', 'username' => 'root', 'password' => '', 'database' => 'my_ci', 'dbdriver' => 'mysqli', 'char_set' => 'utf8mb4', 'dbcollat' => 'utf8mb4_unicode_ci',);Use your configured MySQL password when one is set in .env.
7. Verify DNS
my-ci.lvh.me resolves to 127.0.0.1 by default. For a custom suffix, add a hosts entry:
127.0.0.1 my-ci.example8. Open your browser
Visit http://my-ci.lvh.me or https://my-ci.lvh.me.
Next steps
- Move new projects to CodeIgniter 4 where possible.
- Use Devilbox intranet database tools for inspection.
- Configure HTTPS and Xdebug after the application loads.