Using Composer with Codeigniter

So you want to use composer in your next Codeigniter Project?

Well here’s how to do it:

1. Download and install Codeigniter

2. CD to project directory and install Composer
curl -sS | php

3. Create a composer.json file in your project root and define dependencies
"require": {
"monolog/monolog": "1.2.*"

4. Install Dependecies
php composer.phar install

This will create a vendor directory in your root folder of your project.

5. Add autoload.php to your Codeigniter’s index.php before require_once BASEPATH.’core/CodeIgniter.php’;

include_once './vendor/autoload.php';

Thats’s it. Now you can use your newly installed libraries in CI. Have fun!