Composer 使用方法和常用命令


Composer 常用命令

 

php包的仓库

php package repository https://packagist.org/

 

常用命令

搜索包

composer search packageName

包的安装,自动更新composer.json

composer require packageName packageVersion
ps: 
composer require laravel/lumen-framework:1.9.*
composer require laravel/lumen-framework:dev-master

包的更新,修改composer.json中包版本,然后执行

composer update 
composer update packageName1 packageName2

删除包

composer remove packageName

 

"require": {
    "vendor/package": "1.3.2", // exactly 1.3.2

    // >, <, >=, <= | specify upper / lower bounds
    "vendor/package": ">=1.3.2", // anything above or equal to 1.3.2
    "vendor/package": "<1.3.2", // anything below 1.3.2

    // * | wildcard
    "vendor/package": "1.3.*", // >=1.3.0 <1.4.0

    // ~ | allows last digit specified to go up
    "vendor/package": "~1.3.2", // >=1.3.2 <1.4.0
    "vendor/package": "~1.3", // >=1.3.0 <2.0.0

    // ^ | doesn't allow breaking changes (major version fixed - following semver)
    "vendor/package": "^1.3.2", // >=1.3.2 <2.0.0
    "vendor/package": "^0.3.2", // >=0.3.2 <0.4.0 // except if major version is 0
}

中文文档