Base on an awesome work from kenjis/codeigniter-composer-installer
CodeIgniter Composer Installer
, (*1)
This package installs the offical CodeIgniter (version 3.1.*) with multiple applications project in secure folder structure via Composer., (*2)
Note: If you want to install CodeIgniter4 (under development), see https://github.com/kenjis/codeigniter-composer-installer/tree/4.x., (*3)
You can update CodeIgniter system folder to latest version with one command., (*4)
Folder Structure
codeigniter/
โโโ application/frontend
โโโ application/backend (*)
โโโ application/api (*)
โโโ composer.json
โโโ composer.lock
โโโ public/
โย ย โโโ .htaccess
โย ย โโโ index.php
โโโ vendor/
โโโ codeigniter/
ย ย โโโ framework/
ย ย โโโ system/
You can define yours applications by clone then change composer.json with key, (*5)
{
"name": "Your package name",
"config": {
"apps": {
"backend": {
"source": "application/backend",
"doc_root": "public_html/cpanel"
},
"frontend": {
"source": "application/frontend",
"doc_root": "public_html"
},
"api": {
"source": "application/api",
"doc_root": "public_html/api"
}
}
}
}
Requirements
How to Use
Install CodeIgniter
$ composer create-project quannda/codeigniter-project-seed codeigniter
Above command installs draft source code structure for project in folder codeigniter, with sample 3 applications config in composer.json. Please take a look and make any change if necessary.
Then use, (*6)
cd codeigniter && composer install
Above command installs public/.htaccess to remove index.php in your URL. If you don't need it, please remove it., (*7)
And it changes each application/{app_name}/config/config.php:, (*8)
$config['composer_autoload'] = FALSE;
โ
$config['composer_autoload'] = realpath(APPPATH . '../vendor/autoload.php');
$config['index_page'] = 'index.php';
โ
$config['index_page'] = '';
Install Translations for System Messages
If you want to install translations for system messages:, (*9)
$ cd /path/to/codeigniter
$ php bin/install.php translations 3.1.0
Install Third Party Libraries
Codeigniter Matches CLI:, (*10)
$ php bin/install.php matches-cli master
CodeIgniter HMVC Modules:, (*11)
$ php bin/install.php hmvc-modules master
Modular Extensions - HMVC:, (*12)
$ php bin/install.php modular-extensions-hmvc codeigniter-3.x
Ion Auth:, (*13)
$ php bin/install.php ion-auth 2
CodeIgniter3 Filename Checker:, (*14)
$ php bin/install.php filename-checker master
CodeIgniter Rest Server:, (*15)
$ php bin/install.php restserver 2.7.2
Run PHP built-in server (PHP 5.4 or later)
$ cd /path/to/codeigniter
$ bin/server.sh
Update CodeIgniter
$ cd /path/to/codeigniter
$ composer update
You must update files manually if files in application folder or index.php change. Check CodeIgniter User Guide., (*16)
Reference