Composer
是 PHP 用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer 会帮你安装这些依赖的库文件。
配置文件示例:
修改全局配置:全局配置的文件一般放在
C:\Users\XXX\AppData\Roaming\Composer\config.json; {
"config": {},
"repositories": [
{
"type": "composer",
"url": "http://pkg.phpcomposer.com/repo/packagist/"
},
{
"packagist": false
}
] }
修改当前配置:即项目当前的composer.json文件;
以 laravel 项目的 composer.json 配置文件为例:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "4.2.*"
},
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize""post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
},
"minimum-stability": "stable",
"repositories": [
{
"type": "composer",
"url": "http://pkg.phpcomposer.com/repo/packagist/"
},
{
"packagist": false
}
]
}