The following tutorial column of composer will introduce some commonly used commands\parameters\instructions of composer. I hope it will be helpful to friends in need!
curl -sS https://getcomposer.org/installer | php
or
php -r "readfile('https://getcomposer.org/installer');" | php
Global installation
mv composer.phar /usr/local/bin/composer
composer config -g repo.packagist composer https://packagist.phpcomposer.com
composer install/update --ignore-platform-reqs
Install plug-in package?
composer global require "fxp/composer-asset-plugin:1.2.0“
create-project
You can use Composer to create a new project from an existing package. This is equivalent to executing a git clone
or svn checkout
command to install the dependencies of this package into its own vendor directory.
This command has several common uses:
To create a new Composer-based project, you can use the "create-project" command. Pass a package name and it will create the project's directory for you. You can also specify a version number in the third parameter, otherwise the latest version will be retrieved.
If the directory does not currently exist, it will be automatically created during the installation process.
php composer.phar create-project doctrine/orm path 2.2.*
In addition, you can also start this project through the existing composer.json
file without using this command.
By default, this command will look for the package you specify on packagist.org.
composer
resource library, or a local path pointing to a packages.json
file. stable
. source
. dist
. require-dev
field. self-update
To upgrade Composer itself to the latest version, just run the self-update
command. It will replace your composer.phar
file to the latest version.
php composer.phar self-update
If you want to upgrade to a specific version, you can simply specify it like this:
php composer.phar self-update 1.0.0-alpha7
If you have installed Composer for the entire system (see Global Installation), you may need to Run it under root
permissions:
sudo composer self-update
search
The search
command allows you to search for dependency packages for the current project. Usually it only searches packages on packagist.org , you can simply enter your search criteria.
php composer.phar search monolog
You can also perform a multi-criteria search by passing multiple parameters.
require
##require The command adds a new dependency package to the current directory
composer.json in the file.
php composer.phar require
php composer.phar require vendor/package:2.* vendor/package2:dev-master
.
.
field.
composer.lock file, you should use
update Order.
php composer.phar update
这将解决项目的所有依赖,并将确切的版本号写入 composer.lock
。
如果你只是想更新几个包,你可以像这样分别列出它们:
php composer.phar update vendor/package vendor/package2
你还可以使用通配符进行批量更新:
php composer.phar update vendor/*
source
安装。dist
安装。require-dev
字段中列出的包(这是一个默认值)。require-dev
字段中列出的包。composer.json
文件中定义的脚本。install
install
命令从当前目录读取 composer.json
文件,处理了依赖关系,并把其安装到 vendor
目录下。
php composer.phar install
如果当前目录下存在 composer.lock
文件,它会从此文件读取依赖版本,而不是根据 composer.json
文件去获取依赖。这确保了该库的每个使用者都能得到相同的依赖版本。
如果没有 composer.lock
文件,composer 将在处理完依赖关系后创建它。
source
和 dist
。对于稳定版本 composer 将默认使用 dist
方式。而 source
表示版本控制源 。如果 --prefer-source
是被启用的,composer 将从 source
安装(如果有的话)。如果想要使用一个 bugfix 到你的项目,这是非常有用的。并且可以直接从本地的版本库直接获取依赖关系。--prefer-source
相反,composer 将尽可能的从 dist
获取,这将大幅度的加快在 build servers 上的安装。这也是一个回避 git 问题的途径,如果你不清楚如何正确的设置。--dry-run
命令,它将模拟安装并显示将会发生什么。require-dev
字段中列出的包(这是一个默认值)。require-dev
字段中列出的包。composer.json
文件中定义的脚本。The above is the detailed content of Some commands\parameters\descriptions in composer. For more information, please follow other related articles on the PHP Chinese website!