http://docs.phpcomposer.com/00-intro.md#Installation-*nix
切换到项目目录。增加文件:
[root@localhost html]# vi composer.json
{
"require": {
"monolog/monolog": "1.0.*"
}
}
由于composer是安装在/root下的,所以在项目下,我们这样执行:
[root@localhost html]# php /root/composer.phar install
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing monolog/monolog (1.0.2)
Loading from cache
Writing lock file
Generating autoload files
项目文件a.php中可以增加这行语句,进行自动加载composer下载的包类:
[root@localhost html]# vi /var/www/html/a.php
<?php
require 'vendor/autoload.php';