安装Composer

官方地址

引入项目

创建 composer.json

{
    "require": {
                "monolog/monolog": "*"
    },
    "minimum-stability": "dev"
}

执行命令

composer update

修改配置文件

新版CI

修改config.php

$config[‘composer_autoload’] = ‘./vendor/autoload.php’;

老版CI

在library下创建:MY_Composer

<?php
/**
 * Description of MY_Composer
 *
 * @author Rana
 */
class MY_Composer 
{
    function __construct() 
    {
        include("./vendor/autoload.php");
    }
}

修改autoload.php文件:

$autoload['libraries'] = array('MY_Composer');

参考资料:

http://codesamplez.com/development/composer-with-codeigniter