2012-02-19 14:16:25 +00:00
|
|
|
# Command-line interface
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
You've already learned how to use the command-line interface to do some
|
|
|
|
things. This chapter documents all the available commands.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
## init
|
|
|
|
|
2012-03-07 23:18:03 +00:00
|
|
|
In the [Libraries](02-libraries.md) chapter we looked at how to create a `composer.json` by
|
2012-02-20 10:08:18 +00:00
|
|
|
hand. There is also an `init` command available that makes it a bit easier to
|
|
|
|
do this.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
When you run the command it will interactively ask you to fill in the fields,
|
|
|
|
while using some smart defaults.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar init
|
|
|
|
|
|
|
|
## install
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
The `install` command reads the `composer.json` file from the current
|
|
|
|
directory, resolves the dependencies, and installs them into `vendor`.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar install
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
If there is a `composer.lock` file in the current directory, it will use the
|
|
|
|
exact versions from there instead of resolving them. This ensures that
|
|
|
|
everyone using the library will get the same versions of the dependencies.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
If there is no `composer.lock` file, composer will create one after dependency
|
|
|
|
resolution.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
### Options
|
|
|
|
|
2012-02-26 11:40:35 +00:00
|
|
|
* **--prefer-source:** There are two ways of downloading a package: `source`
|
|
|
|
and `dist`. For stable versions composer will use the `dist` by default.
|
|
|
|
The `source` is a version control repository. If `--prefer-source` is
|
|
|
|
enabled, composer will install from `source` if there is one. This is
|
|
|
|
useful if you want to make a bugfix to a project and get a local git
|
|
|
|
clone of the dependency directly.
|
|
|
|
* **--dry-run:** If you want to run through an installation without actually
|
|
|
|
installing a package, you can use `--dry-run`. This will simulate the
|
|
|
|
installation and show you what would happen.
|
|
|
|
* **--no-install-recommends:** By default composer will install all packages
|
|
|
|
that are referenced by `recommend`. By passing this option you can disable
|
|
|
|
that.
|
|
|
|
* **--install-suggests:** The packages referenced by `suggest` will not be
|
|
|
|
installed by default. By passing this option, you can install them.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
## update
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
In order to get the latest versions of the dependencies and to update the
|
|
|
|
`composer.lock` file, you should use the `update` command.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar update
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
This will resolve all dependencies of the project and write the exact versions
|
|
|
|
into `composer.lock`.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
### Options
|
|
|
|
|
|
|
|
* **--prefer-source:** Install packages from `source` when available.
|
|
|
|
* **--dry-run:** Simulate the command without actually doing anything.
|
|
|
|
* **--no-install-recommends:** Do not install packages referenced by `recommend`.
|
|
|
|
* **--install-suggests:** Install packages referenced by `suggest`.
|
|
|
|
|
|
|
|
## search
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
The search command allows you to search through the current project's package
|
|
|
|
repositories. Usually this will be just packagist. You simply pass it the
|
|
|
|
terms you want to search for.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar search monolog
|
|
|
|
|
|
|
|
You can also search for more than one term by passing multiple arguments.
|
|
|
|
|
|
|
|
## show
|
|
|
|
|
|
|
|
To list all of the available packages, you can use the `show` command.
|
|
|
|
|
|
|
|
$ php composer.phar show
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
If you want to see the details of a certain package, you can pass the package
|
|
|
|
name.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar show monolog/monolog
|
|
|
|
|
|
|
|
name : monolog/monolog
|
|
|
|
versions : master-dev, 1.0.2, 1.0.1, 1.0.0, 1.0.0-RC1
|
|
|
|
type : library
|
|
|
|
names : monolog/monolog
|
|
|
|
source : [git] http://github.com/Seldaek/monolog.git 3d4e60d0cbc4b888fe5ad223d77964428b1978da
|
|
|
|
dist : [zip] http://github.com/Seldaek/monolog/zipball/3d4e60d0cbc4b888fe5ad223d77964428b1978da 3d4e60d0cbc4b888fe5ad223d77964428b1978da
|
|
|
|
license : MIT
|
|
|
|
|
|
|
|
autoload
|
|
|
|
psr-0
|
|
|
|
Monolog : src/
|
|
|
|
|
|
|
|
requires
|
|
|
|
php >=5.3.0
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
You can even pass the package version, which will tell you the details of that
|
|
|
|
specific version.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar show monolog/monolog 1.0.2
|
|
|
|
|
|
|
|
### Options
|
|
|
|
|
|
|
|
* **--installed:** Will list the packages that are installed.
|
2012-03-07 23:18:03 +00:00
|
|
|
* **--platform:** Will list only platform packages (php & extensions).
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
## depends
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
The `depends` command tells you which other packages depend on a certain
|
|
|
|
package. You can specify which link types (`require`, `recommend`, `suggest`)
|
|
|
|
should be included in the listing.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar depends --link-type=require monolog/monolog
|
|
|
|
|
|
|
|
nrk/monolog-fluent
|
|
|
|
poc/poc
|
|
|
|
propel/propel
|
|
|
|
symfony/monolog-bridge
|
|
|
|
symfony/symfony
|
|
|
|
|
|
|
|
### Options
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
* **--link-type:** The link types to match on, can be specified multiple
|
2012-02-26 11:40:35 +00:00
|
|
|
times.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
## validate
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
You should always run the `validate` command before you commit your
|
|
|
|
`composer.json` file, and before you tag a release. It will check if your
|
|
|
|
`composer.json` is valid.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar validate
|
|
|
|
|
|
|
|
## self-update
|
|
|
|
|
2012-02-20 10:08:18 +00:00
|
|
|
To update composer itself to the latest version, just run the `self-update`
|
|
|
|
command. It will replace your `composer.phar` with the latest version.
|
2012-02-19 14:16:25 +00:00
|
|
|
|
|
|
|
$ php composer.phar self-update
|
|
|
|
|
|
|
|
## help
|
|
|
|
|
|
|
|
To get more information about a certain command, just use `help`.
|
|
|
|
|
|
|
|
$ php composer.phar help install
|
2012-02-26 11:40:35 +00:00
|
|
|
|
|
|
|
## Environment variables
|
|
|
|
|
|
|
|
You can set a number of environment variables that override certain settings.
|
|
|
|
Whenever possible it is recommended to specify these settings in the `config`
|
|
|
|
section of `composer.json` instead. It is worth noting that that the env vars
|
|
|
|
will always take precedence over the values specified in `composer.json`.
|
|
|
|
|
|
|
|
### COMPOSER
|
|
|
|
|
|
|
|
By setting the `COMPOSER` env variable is is possible to set the filename of
|
|
|
|
`composer.json` to something else.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
|
|
|
|
$ COMPOSER=composer-other.json php composer.phar install
|
|
|
|
|
|
|
|
### COMPOSER_VENDOR_DIR
|
|
|
|
|
2012-03-06 23:03:35 +00:00
|
|
|
By setting this var you can make composer install the dependencies into a
|
2012-02-26 11:40:35 +00:00
|
|
|
directory other than `vendor`.
|
|
|
|
|
|
|
|
### COMPOSER_BIN_DIR
|
|
|
|
|
2012-03-07 23:18:03 +00:00
|
|
|
By setting this option you can change the `bin` ([Vendor Bins](articles/vendor-bins.md))
|
2012-02-26 11:40:35 +00:00
|
|
|
directory to something other than `vendor/bin`.
|
|
|
|
|
|
|
|
### COMPOSER_PROCESS_TIMEOUT
|
|
|
|
|
|
|
|
This env var controls the time composer waits for commands (such as git
|
|
|
|
commands) to finish executing. The default value is 60 seconds.
|
2012-03-06 23:03:35 +00:00
|
|
|
|
|
|
|
### HTTP_PROXY
|
|
|
|
|
|
|
|
If you are using composer from behind an HTTP proxy, you can use the standard
|
|
|
|
`HTTP_PROXY` or `http_proxy` env vars. Simply set it to the URL of your proxy.
|
|
|
|
Many operating systems already set this variable for you.
|
2012-03-07 16:35:53 +00:00
|
|
|
|
|
|
|
← [Libraries](02-libraries.md) | [Schema](04-schema.md) →
|