2014-07-20 16:47:10 +00:00
# Command-line interface / Commands
2012-02-19 14:16:25 +00:00
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
2020-10-23 19:52:05 +00:00
To get help from the command-line, call `composer` or `composer list`
2012-11-08 14:44:58 +00:00
to see the complete list of commands, then `--help` combined with any of those
can give you more information.
2017-08-16 13:14:29 +00:00
As Composer uses [symfony/console ](https://github.com/symfony/console ) you can call commands by short name if it's not ambiguous.
2022-08-20 10:23:00 +00:00
```shell
2021-10-25 11:11:35 +00:00
php composer.phar dump
2017-08-16 13:14:29 +00:00
```
calls `composer dump-autoload` .
2022-05-13 11:58:02 +00:00
## Bash Completions
2022-07-22 08:16:22 +00:00
To install bash completions you can run `composer completion bash > completion.bash` .
This will create a `completion.bash` file in the current directory.
Then execute `source completion.bash` to enable it in the current terminal session.
Move and rename the `completion.bash` file to `/etc/bash_completion.d/composer` to make
it load automatically in new terminals.
2022-05-13 11:58:02 +00:00
2012-11-08 14:44:58 +00:00
## Global Options
The following options are available with every command:
* **--verbose (-v):** Increase verbosity of messages.
* **--help (-h):** Display help information.
* **--quiet (-q):** Do not output any message.
* **--no-interaction (-n):** Do not ask any interactive question.
2016-04-28 19:12:45 +00:00
* **--no-plugins:** Disables plugins.
2021-12-20 13:23:35 +00:00
* **--no-scripts:** Skips execution of scripts defined in `composer.json` .
2019-01-28 14:29:37 +00:00
* **--no-cache:** Disables the use of the cache directory. Same as setting the COMPOSER_CACHE_DIR
env var to /dev/null (or NUL on Windows).
2012-11-08 14:44:58 +00:00
* **--working-dir (-d):** If specified, use the given directory as working directory.
* **--profile:** Display timing and memory usage information
* **--ansi:** Force ANSI output.
* **--no-ansi:** Disable ANSI output.
* **--version (-V):** Display this application version.
2013-05-04 08:46:10 +00:00
## Process Exit Codes
* **0:** OK
* **1:** Generic/unknown error code
* **2:** Dependency solving error code
2012-02-19 14:16:25 +00:00
## init
2012-05-30 21:55:04 +00:00
In the [Libraries ](02-libraries.md ) chapter we looked at how to create a
2020-10-23 19:52:05 +00:00
`composer.json` by hand. There is also an `init` command available 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
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar init
```
2012-02-19 14:16:25 +00:00
2012-05-30 21:55:04 +00:00
### Options
* **--name:** Name of the package.
* **--description:** Description of the package.
* **--author:** Author name of the package.
2017-03-21 13:57:46 +00:00
* **--type:** Type of package.
2012-05-30 21:55:04 +00:00
* **--homepage:** Homepage of the package.
* **--require:** Package to require with a version constraint. Should be
in format `foo/bar:1.0.0` .
* **--require-dev:** Development requirements, see ** --require**.
2012-11-30 16:10:37 +00:00
* **--stability (-s):** Value for the `minimum-stability` field.
2017-03-21 13:57:46 +00:00
* **--license (-l):** License of package.
2016-02-29 17:32:32 +00:00
* **--repository:** Provide one (or more) custom repositories. They will be stored
in the generated composer.json, and used for auto-completion when prompting for
the list of requires. Every repository can be either an HTTP URL pointing
2023-08-30 16:03:12 +00:00
to a `composer` repository or a JSON string which is similar to what the
2016-02-29 17:32:32 +00:00
[repositories ](04-schema.md#repositories ) key accepts.
2021-04-20 19:58:38 +00:00
* **--autoload (-a):** Add a PSR-4 autoload mapping to the composer.json. Automatically maps your package's namespace to the provided directory. (Expects a relative path, e.g. src/) See also [PSR-4 autoload ](04-schema.md#psr-4 ).
2012-05-30 21:55:04 +00:00
2018-07-11 17:21:09 +00:00
## install / i
2012-02-19 14:16:25 +00:00
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
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar install
```
2012-02-19 14:16:25 +00:00
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
2015-06-22 09:08:23 +00:00
If there is no `composer.lock` file, Composer will create one after dependency
2012-02-20 10:08:18 +00:00
resolution.
2012-02-19 14:16:25 +00:00
### Options
2021-04-07 14:04:42 +00:00
* **--prefer-install:** There are two ways of downloading a package: `source`
and `dist` . Composer uses `dist` by default. If you pass
`--prefer-install=source` (or `--prefer-source` ) 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.
To get the legacy behavior where Composer use `source` automatically for dev
versions of packages, use `--prefer-install=auto` . See also [config.preferred-install ](06-config.md#preferred-install ).
Passing this flag will override the config value.
2012-02-26 11:40:35 +00:00
* **--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.
2022-10-12 11:56:35 +00:00
* **--download-only:** Download only, do not install packages.
2013-06-04 13:21:44 +00:00
* **--dev:** Install packages listed in `require-dev` (this is the default behavior).
2015-06-24 06:43:07 +00:00
* **--no-dev:** Skip installing packages listed in `require-dev` . The autoloader
2022-08-16 09:28:46 +00:00
generation skips the `autoload-dev` rules. Also see [COMPOSER_NO_DEV ](#composer-no-dev ).
2014-11-21 21:28:44 +00:00
* **--no-autoloader:** Skips autoloader generation.
2012-12-13 16:19:58 +00:00
* **--no-progress:** Removes the progress display that can mess with some
terminals or scripts which don't handle backspace characters.
2022-06-24 14:54:30 +00:00
* **--audit:** Run an audit after installation is complete.
2022-07-25 11:13:32 +00:00
* **--audit-format:** Audit output format. Must be "table", "plain", "json", or "summary" (default).
2014-01-03 15:46:56 +00:00
* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
2012-11-08 14:44:58 +00:00
autoloader. This is recommended especially for production, but can take
a bit of time to run so it is currently not done by default.
2015-08-16 19:56:52 +00:00
* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
Implicitly enables `--optimize-autoloader` .
2016-07-28 08:23:39 +00:00
* **--apcu-autoloader:** Use APCu to cache found/not-found classes.
2020-10-13 08:22:46 +00:00
* **--apcu-autoloader-prefix:** Use a custom prefix for the APCu autoloader cache.
Implicitly enables `--apcu-autoloader` .
2020-06-02 09:17:49 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these.
2020-06-01 13:43:24 +00:00
See also the [`platform` ](06-config.md#platform ) config option.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
2021-11-28 12:29:54 +00:00
does not fulfill it. Multiple requirements can be ignored via wildcard. Appending
a `+` makes it only ignore the upper-bound of the requirements. For example, if a package
2021-12-19 11:38:19 +00:00
requires `php: ^7` , then the option `--ignore-platform-req=php+` would allow installing on PHP 8,
2021-11-28 12:29:54 +00:00
but installation on PHP 5.6 would still fail.
2012-02-19 14:16:25 +00:00
2022-10-12 08:55:57 +00:00
## update / u / upgrade
2012-02-19 14:16:25 +00:00
2012-02-20 10:08:18 +00:00
In order to get the latest versions of the dependencies and to update the
2017-09-11 14:13:33 +00:00
`composer.lock` file, you should use the `update` command. This command is also
aliased as `upgrade` as it does the same as `upgrade` does if you are thinking
of `apt-get` or similar package managers.
2012-02-19 14:16:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar update
```
2012-02-19 14:16:25 +00:00
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
2018-03-23 10:37:33 +00:00
If you only want to update a few packages and not all, you can list them as such:
2012-05-26 13:27:35 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar update vendor/package vendor/package2
```
2012-05-26 13:27:35 +00:00
2012-12-13 14:06:06 +00:00
You can also use wildcards to update a bunch of packages at once:
2012-12-13 09:08:04 +00:00
2022-08-20 10:23:00 +00:00
```shell
2019-02-10 11:40:11 +00:00
php composer.phar update "vendor/*"
2014-05-19 10:17:07 +00:00
```
2012-12-13 09:08:04 +00:00
2020-05-01 14:56:17 +00:00
If you want to downgrade a package to a specific version without changing your
composer.json you can use `--with` and provide a custom version constraint:
2022-08-20 10:23:00 +00:00
```shell
2020-05-01 14:56:17 +00:00
php composer.phar update --with vendor/package:2.0.1
```
2022-01-21 16:39:57 +00:00
Note that with the above all packages will be updated. If you only want to
update the package(s) for which you provide custom constraints using `--with` ,
you can skip `--with` and instead use constraints with the partial update syntax:
2020-05-01 14:56:17 +00:00
2022-08-20 10:23:00 +00:00
```shell
2020-05-01 14:56:17 +00:00
php composer.phar update vendor/package:2.0.1 vendor/package2:3.0.*
```
2022-10-11 11:34:45 +00:00
> **Note:** For packages also required in your composer.json the custom constraint
> must be a subset of the existing constraint. The composer.json constraints still
> apply and the composer.json is not modified by these temporary update constraints.
2022-01-21 16:39:57 +00:00
2020-05-01 14:56:17 +00:00
2012-02-19 14:16:25 +00:00
### Options
2021-04-07 14:04:42 +00:00
* **--prefer-install:** There are two ways of downloading a package: `source`
and `dist` . Composer uses `dist` by default. If you pass
`--prefer-install=source` (or `--prefer-source` ) 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.
To get the legacy behavior where Composer use `source` automatically for dev
versions of packages, use `--prefer-install=auto` . See also [config.preferred-install ](06-config.md#preferred-install ).
Passing this flag will override the config value.
2012-02-19 14:16:25 +00:00
* **--dry-run:** Simulate the command without actually doing anything.
2013-06-04 13:21:44 +00:00
* **--dev:** Install packages listed in `require-dev` (this is the default behavior).
2022-08-16 09:28:46 +00:00
* **--no-dev:** Skip installing packages listed in `require-dev` . The autoloader generation skips the `autoload-dev` rules. Also see [COMPOSER_NO_DEV ](#composer-no-dev ).
2020-03-04 17:30:50 +00:00
* **--no-install:** Does not run the install step after updating the composer.lock file.
2022-08-17 09:44:18 +00:00
* **--no-audit:** Does not run the audit steps after updating the composer.lock file. Also see [COMPOSER_NO_AUDIT ](#composer-no-audit ).
2022-07-25 11:13:32 +00:00
* **--audit-format:** Audit output format. Must be "table", "plain", "json", or "summary" (default).
2024-01-10 09:25:49 +00:00
* **--lock:** Overwrites the lock file hash to suppress warning about the lock file being out of
date without updating package versions. Package metadata like mirrors and URLs are updated if
they changed.
2020-05-01 14:56:17 +00:00
* **--with:** Temporary version constraint to add, e.g. foo/bar:1.0.0 or foo/bar=1.0.0
2014-11-21 21:28:44 +00:00
* **--no-autoloader:** Skips autoloader generation.
2012-12-13 16:19:58 +00:00
* **--no-progress:** Removes the progress display that can mess with some
terminals or scripts which don't handle backspace characters.
2020-10-12 08:36:12 +00:00
* **--with-dependencies (-w):** Update also dependencies of packages in the argument list, except those which are root requirements.
* **--with-all-dependencies (-W):** Update also dependencies of packages in the argument list, including those which are root requirements.
2014-01-03 15:46:56 +00:00
* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
2012-11-08 14:44:58 +00:00
autoloader. This is recommended especially for production, but can take
2020-06-30 15:39:56 +00:00
a bit of time to run, so it is currently not done by default.
2015-08-16 19:56:52 +00:00
* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
Implicitly enables `--optimize-autoloader` .
2016-07-28 08:23:39 +00:00
* **--apcu-autoloader:** Use APCu to cache found/not-found classes.
2020-10-13 08:22:46 +00:00
* **--apcu-autoloader-prefix:** Use a custom prefix for the APCu autoloader cache.
Implicitly enables `--apcu-autoloader` .
2020-06-02 09:17:49 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these.
2020-06-01 13:43:24 +00:00
See also the [`platform` ](06-config.md#platform ) config option.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
2021-11-28 12:29:54 +00:00
does not fulfill it. Multiple requirements can be ignored via wildcard. Appending
a `+` makes it only ignore the upper-bound of the requirements. For example, if a package
2021-12-19 11:38:19 +00:00
requires `php: ^7` , then the option `--ignore-platform-req=php+` would allow installing on PHP 8,
2021-11-28 12:29:54 +00:00
but installation on PHP 5.6 would still fail.
2022-07-20 20:29:27 +00:00
* **--prefer-stable:** Prefer stable versions of dependencies. Can also be set via the
COMPOSER_PREFER_STABLE=1 env var.
2014-12-13 22:56:15 +00:00
* **--prefer-lowest:** Prefer lowest versions of dependencies. Useful for testing minimal
2022-07-20 20:29:27 +00:00
versions of requirements, generally used with `--prefer-stable` . Can also be set via the
COMPOSER_PREFER_LOWEST=1 env var.
2024-02-08 10:31:40 +00:00
* **--minimal-changes (-m):** During a partial update with `-w` /`-W`, only perform absolutely necessary
2023-10-26 08:25:04 +00:00
changes to transitive dependencies. Can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var.
2017-03-21 13:57:46 +00:00
* **--interactive:** Interactive interface with autocompletion to select the packages to update.
* **--root-reqs:** Restricts the update to your first degree dependencies.
2012-02-19 14:16:25 +00:00
2020-04-30 17:50:53 +00:00
Specifying one of the words `mirrors` , `lock` , or `nothing` as an argument has the same effect as specifying the option `--lock` , for example `composer update mirrors` is exactly the same as `composer update --lock` .
2022-07-18 11:04:49 +00:00
## require / r
2012-03-31 22:39:43 +00:00
2012-05-30 21:55:04 +00:00
The `require` command adds new packages to the `composer.json` file from
2014-10-04 16:23:04 +00:00
the current directory. If no file exists one will be created on the fly.
2012-03-31 22:39:43 +00:00
2024-02-06 12:27:55 +00:00
If you do not specify a package, Composer will prompt you to search for a package, and given
results, provide a list of matches to require.
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar require
```
2012-03-31 22:39:43 +00:00
2012-05-26 13:27:35 +00:00
After adding/changing the requirements, the modified requirements will be
2012-05-30 21:55:04 +00:00
installed or updated.
2012-05-26 13:27:35 +00:00
2018-03-23 10:37:33 +00:00
If you do not want to choose requirements interactively, you can pass them
2012-05-26 13:27:35 +00:00
to the command.
2022-08-20 10:23:00 +00:00
```shell
2020-02-07 13:29:05 +00:00
php composer.phar require "vendor/package:2.*" vendor/package2:dev-master
2014-05-19 10:17:07 +00:00
```
2012-03-31 22:39:43 +00:00
2024-02-06 12:27:55 +00:00
If you do not specify a version constraint, composer will choose a suitable one based
on the available package versions.
```shell
php composer.phar require vendor/package vendor/package2
```
If you do not want to install the new dependencies immediately you can call it with --no-update
2017-12-14 16:44:54 +00:00
2012-05-26 13:27:35 +00:00
### Options
2017-03-21 13:57:46 +00:00
* **--dev:** Add packages to `require-dev` .
2020-01-31 13:34:10 +00:00
* **--dry-run:** Simulate the command without actually doing anything.
2021-04-07 14:04:42 +00:00
* **--prefer-install:** There are two ways of downloading a package: `source`
and `dist` . Composer uses `dist` by default. If you pass
`--prefer-install=source` (or `--prefer-source` ) 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.
To get the legacy behavior where Composer use `source` automatically for dev
versions of packages, use `--prefer-install=auto` . See also [config.preferred-install ](06-config.md#preferred-install ).
Passing this flag will override the config value.
2012-12-13 16:19:58 +00:00
* **--no-progress:** Removes the progress display that can mess with some
terminals or scripts which don't handle backspace characters.
2020-03-04 17:30:50 +00:00
* **--no-update:** Disables the automatic update of the dependencies (implies --no-install).
* **--no-install:** Does not run the install step after updating the composer.lock file.
2022-08-17 09:44:18 +00:00
* **--no-audit:** Does not run the audit steps after updating the composer.lock file. Also see [COMPOSER_NO_AUDIT ](#composer-no-audit ).
2022-07-25 11:13:32 +00:00
* **--audit-format:** Audit output format. Must be "table", "plain", "json", or "summary" (default).
2022-08-16 09:28:46 +00:00
* **--update-no-dev:** Run the dependency update with the `--no-dev` option. Also see [COMPOSER_NO_DEV ](#composer-no-dev ).
2020-10-12 08:36:12 +00:00
* **--update-with-dependencies (-w):** Also update dependencies of the newly required packages, except those that are root requirements.
* **--update-with-all-dependencies (-W):** Also update dependencies of the newly required packages, including those that are root requirements.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these.
2020-06-01 13:43:24 +00:00
See also the [`platform` ](06-config.md#platform ) config option.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
2021-11-11 14:56:38 +00:00
does not fulfill it. Multiple requirements can be ignored via wildcard.
2022-07-20 20:29:27 +00:00
* **--prefer-stable:** Prefer stable versions of dependencies. Can also be set via the
COMPOSER_PREFER_STABLE=1 env var.
2017-03-21 13:57:46 +00:00
* **--prefer-lowest:** Prefer lowest versions of dependencies. Useful for testing minimal
2022-07-20 20:29:27 +00:00
versions of requirements, generally used with `--prefer-stable` . Can also be set via the
COMPOSER_PREFER_LOWEST=1 env var.
2024-02-08 10:31:40 +00:00
* **--minimal-changes (-m):** During an update with `-w` /`-W`, only perform absolutely necessary
2023-10-26 08:25:04 +00:00
changes to transitive dependencies. Can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var.
2015-07-09 01:42:52 +00:00
* **--sort-packages:** Keep packages sorted in `composer.json` .
2015-08-18 15:54:56 +00:00
* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to
get a faster autoloader. This is recommended especially for production, but
2020-06-30 15:39:56 +00:00
can take a bit of time to run, so it is currently not done by default.
2015-08-18 15:54:56 +00:00
* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
Implicitly enables `--optimize-autoloader` .
2016-07-28 08:23:39 +00:00
* **--apcu-autoloader:** Use APCu to cache found/not-found classes.
2020-10-13 08:22:46 +00:00
* **--apcu-autoloader-prefix:** Use a custom prefix for the APCu autoloader cache.
Implicitly enables `--apcu-autoloader` .
2017-03-21 13:57:46 +00:00
2024-04-29 09:03:24 +00:00
## remove / rm / uninstall
2013-12-04 07:54:41 +00:00
The `remove` command removes packages from the `composer.json` file from
the current directory.
2022-08-20 10:23:00 +00:00
```shell
2014-07-19 20:21:46 +00:00
php composer.phar remove vendor/package vendor/package2
```
2013-12-04 07:54:41 +00:00
After removing the requirements, the modified requirements will be
uninstalled.
### Options
2022-12-21 09:16:02 +00:00
* **--unused** Remove unused packages that are not a direct or indirect dependency (anymore)
2014-07-19 20:21:46 +00:00
* **--dev:** Remove packages from `require-dev` .
2020-01-31 13:34:10 +00:00
* **--dry-run:** Simulate the command without actually doing anything.
2014-07-19 20:21:46 +00:00
* **--no-progress:** Removes the progress display that can mess with some
terminals or scripts which don't handle backspace characters.
2020-03-04 17:30:50 +00:00
* **--no-update:** Disables the automatic update of the dependencies (implies --no-install).
* **--no-install:** Does not run the install step after updating the composer.lock file.
2022-08-17 09:44:18 +00:00
* **--no-audit:** Does not run the audit steps after installation is complete. Also see [COMPOSER_NO_AUDIT ](#composer-no-audit ).
2022-07-25 11:13:32 +00:00
* **--audit-format:** Audit output format. Must be "table", "plain", "json", or "summary" (default).
2022-08-16 09:28:46 +00:00
* **--update-no-dev:** Run the dependency update with the --no-dev option. Also see [COMPOSER_NO_DEV ](#composer-no-dev ).
2020-10-12 08:36:12 +00:00
* **--update-with-dependencies (-w):** Also update dependencies of the removed packages.
2021-02-24 20:17:05 +00:00
(Deprecated, is now default behavior)
2020-10-12 08:36:12 +00:00
* **--update-with-all-dependencies (-W):** Allows all inherited dependencies to be updated,
including those that are root requirements.
2024-02-08 10:31:40 +00:00
* **--minimal-changes (-m):** During an update with `-w` /`-W`, only perform absolutely necessary
2023-10-26 08:25:04 +00:00
changes to transitive dependencies. Can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these.
2020-06-01 13:43:24 +00:00
See also the [`platform` ](06-config.md#platform ) config option.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
2021-11-11 14:56:38 +00:00
does not fulfill it. Multiple requirements can be ignored via wildcard.
2015-08-18 15:54:56 +00:00
* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to
get a faster autoloader. This is recommended especially for production, but
can take a bit of time to run so it is currently not done by default.
* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
Implicitly enables `--optimize-autoloader` .
2016-07-28 08:23:39 +00:00
* **--apcu-autoloader:** Use APCu to cache found/not-found classes.
2020-10-13 08:22:46 +00:00
* **--apcu-autoloader-prefix:** Use a custom prefix for the APCu autoloader cache.
Implicitly enables `--apcu-autoloader` .
2013-12-04 07:54:41 +00:00
2022-06-09 09:43:59 +00:00
## bump
The `bump` command increases the lower limit of your composer.json requirements
to the currently installed versions. This helps to ensure your dependencies do not
accidentally get downgraded due to some other conflict, and can slightly improve
dependency resolution performance as it limits the amount of package versions
Composer has to look at.
Running this blindly on libraries is **NOT** recommended as it will narrow down
your allowed dependencies, which may cause dependency hell for your users.
Running it with `--dev-only` on libraries may be fine however as dev requirements
are local to the library and do not affect consumers of the package.
### Options
* **--dev-only:** Only bump requirements in "require-dev".
* **--no-dev-only:** Only bump requirements in "require".
2022-09-19 06:45:49 +00:00
* **--dry-run:** Outputs the packages to bump, but will not execute anything.
2022-06-09 09:43:59 +00:00
2021-05-25 20:30:15 +00:00
## reinstall
The `reinstall` command looks up installed packages by name,
uninstalls them and reinstalls them. This lets you do a clean install
of a package if you messed with its files, or if you wish to change
the installation type using --prefer-install.
2022-08-20 10:23:00 +00:00
```shell
2021-05-25 20:30:15 +00:00
php composer.phar reinstall acme/foo acme/bar
```
You can specify more than one package name to reinstall, or use a
wildcard to select several packages at once:
2022-08-20 10:23:00 +00:00
```shell
2021-05-25 20:30:15 +00:00
php composer.phar reinstall "acme/*"
```
### Options
* **--prefer-install:** There are two ways of downloading a package: `source`
and `dist` . Composer uses `dist` by default. If you pass
`--prefer-install=source` (or `--prefer-source` ) 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.
To get the legacy behavior where Composer use `source` automatically for dev
versions of packages, use `--prefer-install=auto` . See also [config.preferred-install ](06-config.md#preferred-install ).
Passing this flag will override the config value.
* **--no-autoloader:** Skips autoloader generation.
* **--no-progress:** Removes the progress display that can mess with some
terminals or scripts which don't handle backspace characters.
* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
autoloader. This is recommended especially for production, but can take
a bit of time to run so it is currently not done by default.
* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
Implicitly enables `--optimize-autoloader` .
* **--apcu-autoloader:** Use APCu to cache found/not-found classes.
* **--apcu-autoloader-prefix:** Use a custom prefix for the APCu autoloader cache.
Implicitly enables `--apcu-autoloader` .
* **--ignore-platform-reqs:** ignore all platform requirements. This only
has an effect in the context of the autoloader generation for the
reinstall command.
* **--ignore-platform-req:** ignore a specific platform requirement. This only
has an effect in the context of the autoloader generation for the
2021-11-11 14:56:38 +00:00
reinstall command. Multiple requirements can be ignored via wildcard.
2021-05-25 20:30:15 +00:00
2017-12-16 21:04:48 +00:00
## check-platform-reqs
The check-platform-reqs command checks that your PHP and extensions versions
match the platform requirements of the installed packages. This can be used
to verify that a production server has all the extensions needed to run a
project after installing it for example.
2019-07-29 14:37:35 +00:00
Unlike update/install, this command will ignore config.platform settings and
check the real platform packages so you can be certain you have the required
platform dependencies.
2022-08-16 12:19:53 +00:00
### Options
* **--lock:** Checks requirements only from the lock file, not from installed packages.
* **--no-dev:** Disables checking of require-dev packages requirements.
* **--format (-f):** Format of the output: text (default) or json
2013-08-17 01:45:51 +00:00
## global
2017-11-15 10:06:24 +00:00
The global command allows you to run other commands like `install` , `remove` , `require`
2013-10-13 09:52:28 +00:00
or `update` as if you were running them from the [COMPOSER_HOME ](#composer-home )
2013-08-17 01:45:51 +00:00
directory.
2016-01-09 19:08:22 +00:00
This is merely a helper to manage a project stored in a central location that
can hold CLI tools or Composer plugins that you want to have available everywhere.
2016-04-27 08:02:49 +00:00
This can be used to install CLI utilities globally. Here is an example:
2013-08-17 01:45:51 +00:00
2022-08-20 10:23:00 +00:00
```shell
2017-11-03 10:49:42 +00:00
php composer.phar global require friendsofphp/php-cs-fixer
2014-05-19 10:17:07 +00:00
```
2013-08-17 01:45:51 +00:00
2018-03-23 10:37:33 +00:00
Now the `php-cs-fixer` binary is available globally. Make sure your global
2016-04-27 08:02:49 +00:00
[vendor binaries ](articles/vendor-binaries.md ) directory is in your `$PATH`
environment variable, you can get its location with the following command :
2022-08-20 10:23:00 +00:00
```shell
2016-04-27 08:02:49 +00:00
php composer.phar global config bin-dir --absolute
```
2018-03-23 10:37:33 +00:00
If you wish to update the binary later on you can run a global update:
2013-08-17 01:45:51 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar global update
```
2013-08-17 01:45:51 +00:00
2012-02-19 14:16:25 +00:00
## search
2012-02-20 10:08:18 +00:00
The search command allows you to search through the current project's package
2020-10-23 19:52:05 +00:00
repositories. Usually this will be packagist. You pass it the terms you want
to search for.
2012-02-19 14:16:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar search monolog
```
2012-02-19 14:16:25 +00:00
You can also search for more than one term by passing multiple arguments.
2012-11-30 16:15:36 +00:00
### Options
2021-12-08 10:45:18 +00:00
* **--only-name (-N):** Search only in package names.
* **--only-vendor (-O):** Search only for vendor / organization names, returns only "vendor"
2021-12-19 14:15:21 +00:00
as a result.
2017-03-21 13:57:46 +00:00
* **--type (-t):** Search for a specific package type.
2021-03-09 22:06:02 +00:00
* **--format (-f):** Lets you pick between text (default) or json output format.
Note that in the json, only the name and description keys are guaranteed to be
present. The rest (`url`, `repository` , `downloads` and `favers` ) are available
for Packagist.org search results and other repositories may return more or less
data.
2012-11-30 16:15:36 +00:00
2022-10-12 08:55:57 +00:00
## show / info
2012-02-19 14:16:25 +00:00
To list all of the available packages, you can use the `show` command.
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar show
```
2012-02-19 14:16:25 +00:00
2016-04-19 10:31:41 +00:00
To filter the list you can pass a package mask using wildcards.
2022-08-20 10:23:00 +00:00
```shell
php composer.phar show "monolog/*"
```
```text
monolog/monolog 2.4.0 Sends your logs to files, sockets, inboxes, databases and various web services
2016-04-19 10:31:41 +00:00
```
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
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar show monolog/monolog
2022-08-20 10:23:00 +00:00
```
```text
2014-05-19 10:17:07 +00:00
name : monolog/monolog
2022-08-20 10:23:00 +00:00
descrip. : Sends your logs to files, sockets, inboxes, databases and various web services
keywords : log, logging, psr-3
versions : * 1.27.1
2014-05-19 10:17:07 +00:00
type : library
2022-08-20 10:23:00 +00:00
license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : http://github.com/Seldaek/monolog
source : [git] https://github.com/Seldaek/monolog.git 904713c5929655dc9b97288b69cfeedad610c9a1
dist : [zip] https://api.github.com/repos/Seldaek/monolog/zipball/904713c5929655dc9b97288b69cfeedad610c9a1 904713c5929655dc9b97288b69cfeedad610c9a1
names : monolog/monolog, psr/log-implementation
support
issues : https://github.com/Seldaek/monolog/issues
source : https://github.com/Seldaek/monolog/tree/1.27.1
2012-02-19 14:16:25 +00:00
2014-05-19 10:17:07 +00:00
autoload
2022-08-20 10:23:00 +00:00
psr-4
Monolog\ => src/Monolog
2012-02-19 14:16:25 +00:00
2014-05-19 10:17:07 +00:00
requires
php >=5.3.0
2022-08-20 10:23:00 +00:00
psr/log ~1.0
2014-05-19 10:17:07 +00:00
```
2012-02-19 14:16:25 +00:00
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
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar show monolog/monolog 1.0.2
```
2012-02-19 14:16:25 +00:00
### Options
2022-06-09 09:45:32 +00:00
* **--all:** List all packages available in all your repositories.
2016-04-19 10:31:41 +00:00
* **--installed (-i):** List the packages that are installed (this is enabled by default, and deprecated).
2020-04-28 06:53:23 +00:00
* **--locked:** List the locked packages from composer.lock.
2012-11-08 14:44:58 +00:00
* **--platform (-p):** List only platform packages (php & extensions).
2017-03-21 13:57:46 +00:00
* **--available (-a):** List available packages only.
2012-11-08 14:44:58 +00:00
* **--self (-s):** List the root package info.
2016-04-19 10:31:41 +00:00
* **--name-only (-N):** List package names only.
* **--path (-P):** List package paths.
2017-03-21 13:57:46 +00:00
* **--tree (-t):** List your dependencies as a tree. If you pass a package name it will show the dependency tree for that package.
* **--latest (-l):** List all installed packages including their latest version.
2016-04-24 14:17:08 +00:00
* **--outdated (-o):** Implies --latest, but this lists *only* packages that have a newer version available.
2024-02-06 15:59:01 +00:00
* **--ignore:** Ignore specified package(s). Can contain wildcards (`*`). Use it with the --outdated option if you don't want to be informed about new versions of some packages
2020-06-17 11:15:11 +00:00
* **--no-dev:** Filters dev dependencies from the package list.
2022-06-09 09:45:32 +00:00
* **--major-only (-M):** Use with --latest or --outdated. Only shows packages that have major SemVer-compatible updates.
* **--minor-only (-m):** Use with --latest or --outdated. Only shows packages that have minor SemVer-compatible updates.
2022-07-20 19:06:14 +00:00
* **--patch-only:** Use with --latest or --outdated. Only shows packages that have patch-level SemVer-compatible updates.
2023-12-20 14:37:27 +00:00
* **--sort-by-age (-A):** Displays the installed version's age, and sorts packages oldest first. Use with the --latest or --outdated option.
2016-04-24 14:17:08 +00:00
* **--direct (-D):** Restricts the list of packages to your direct dependencies.
2017-03-21 13:57:46 +00:00
* **--strict:** Return a non-zero exit code when there are outdated packages.
2017-03-07 13:19:51 +00:00
* **--format (-f):** Lets you pick between text (default) or json output format.
2021-11-23 16:16:58 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these. Use with the --outdated option.
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
does not fulfill it. Multiple requirements can be ignored via wildcard. Use with
the --outdated option.
2012-02-19 14:16:25 +00:00
2016-04-22 20:54:04 +00:00
## outdated
2016-04-28 18:48:56 +00:00
The `outdated` command shows a list of installed packages that have updates available,
including their current and latest versions. This is basically an alias for
`composer show -lo` .
2016-04-22 20:54:04 +00:00
The color coding is as such:
2017-03-07 13:19:51 +00:00
- **green (=)**: Dependency is in the latest version and is up to date.
2020-10-24 13:37:35 +00:00
- **yellow (`~`)**: Dependency has a new version available that includes backwards compatibility breaks according to semver, so upgrade when
2016-04-22 20:54:04 +00:00
you can but it may involve work.
2017-03-07 13:19:51 +00:00
- **red (!)**: Dependency has a new version that is semver-compatible and you should upgrade it.
2016-04-22 20:54:04 +00:00
2016-04-24 14:17:08 +00:00
### Options
2022-06-09 09:45:32 +00:00
* **--all (-a):** Show all packages, not just outdated (alias for `composer show --latest` ).
2016-04-24 14:17:08 +00:00
* **--direct (-D):** Restricts the list of packages to your direct dependencies.
2017-03-07 13:19:51 +00:00
* **--strict:** Returns non-zero exit code if any package is outdated.
2024-02-06 15:59:01 +00:00
* **--ignore:** Ignore specified package(s). Can contain wildcards (`*`). Use it if you don't want to be informed about new versions of some packages
2022-06-09 09:45:32 +00:00
* **--major-only (-M):** Only shows packages that have major SemVer-compatible updates.
2017-03-21 13:57:46 +00:00
* **--minor-only (-m):** Only shows packages that have minor SemVer-compatible updates.
2022-06-09 09:45:32 +00:00
* **--patch-only (-p):** Only shows packages that have patch-level SemVer-compatible updates.
2023-12-20 14:37:27 +00:00
* **--sort-by-age (-A):** Displays the installed version's age, and sorts packages oldest first.
2017-03-07 13:19:51 +00:00
* **--format (-f):** Lets you pick between text (default) or json output format.
2020-06-17 11:15:11 +00:00
* **--no-dev:** Do not show outdated dev dependencies.
2020-10-26 13:47:31 +00:00
* **--locked:** Shows updates for packages from the lock file, regardless of what is currently in vendor dir.
2021-11-23 16:16:58 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these.
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
does not fulfill it. Multiple requirements can be ignored via wildcard.
2016-04-24 14:17:08 +00:00
2014-07-20 16:46:44 +00:00
## browse / home
The `browse` (aliased to `home` ) opens a package's repository URL or homepage
in your browser.
### Options
* **--homepage (-H):** Open the homepage instead of the repository URL.
2017-03-21 13:57:46 +00:00
* **--show (-s):** Only show the homepage or repository URL.
2014-07-20 16:46:44 +00:00
2014-03-17 11:26:19 +00:00
## suggests
2021-12-19 14:15:21 +00:00
Lists all packages suggested by the currently installed set of packages. You can
2015-06-23 20:44:02 +00:00
optionally pass one or multiple package names in the format of `vendor/package`
to limit output to suggestions made by those packages only.
2014-03-17 11:26:19 +00:00
2020-02-13 15:02:31 +00:00
Use the `--by-package` (default) or `--by-suggestion` flags to group the output by
2016-02-14 20:31:15 +00:00
the package offering the suggestions or the suggested packages respectively.
2020-02-13 15:02:31 +00:00
If you only want a list of suggested package names, use `--list` .
2017-03-21 13:57:46 +00:00
2014-03-17 11:26:19 +00:00
### Options
2020-02-13 15:02:31 +00:00
* **--by-package:** Groups output by suggesting package (default).
2016-02-14 20:31:15 +00:00
* **--by-suggestion:** Groups output by suggested package.
2020-03-10 14:09:28 +00:00
* **--all:** Show suggestions from all dependencies, including transitive ones (by
default only direct dependencies' suggestions are shown).
2020-02-13 15:02:31 +00:00
* **--list:** Show only list of suggested package names.
2015-06-24 06:43:07 +00:00
* **--no-dev:** Excludes suggestions from `require-dev` packages.
2014-03-17 11:26:19 +00:00
2020-02-14 13:08:26 +00:00
## fund
Discover how to help fund the maintenance of your dependencies. This lists
2021-02-25 15:54:26 +00:00
all funding links from the installed dependencies. Use `--format=json` to
get machine-readable output.
### Options
2021-03-09 20:49:54 +00:00
* **--format (-f):** Lets you pick between text (default) or json output format.
2020-02-14 13:08:26 +00:00
2022-10-12 08:55:57 +00:00
## depends / why
2012-02-19 14:16:25 +00:00
2012-02-20 10:08:18 +00:00
The `depends` command tells you which other packages depend on a certain
2016-02-16 15:50:06 +00:00
package. As with installation `require-dev` relationships are only considered
for the root package.
2012-02-19 14:16:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2016-02-16 15:50:06 +00:00
php composer.phar depends doctrine/lexer
2022-08-20 10:23:00 +00:00
```
```text
doctrine/annotations 1.13.3 requires doctrine/lexer (1.*)
doctrine/common 2.13.3 requires doctrine/lexer (^1.0)
2016-02-16 15:50:06 +00:00
```
2016-02-20 00:53:51 +00:00
You can optionally specify a version constraint after the package to limit the
search.
2012-02-19 14:16:25 +00:00
2016-02-20 00:53:51 +00:00
Add the `--tree` or `-t` flag to show a recursive tree of why the package is
depended upon, for example:
2016-01-11 08:52:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2016-02-16 15:50:06 +00:00
php composer.phar depends psr/log -t
2022-08-20 10:23:00 +00:00
```
```text
psr/log 1.1.4 Common interface for logging libraries
├──composer/composer 2.4.x-dev (requires psr/log ^1.0 || ^2.0 || ^3.0)
├──composer/composer dev-main (requires psr/log ^1.0 || ^2.0 || ^3.0)
├──composer/xdebug-handler 3.0.3 (requires psr/log ^1 || ^2 || ^3)
│ ├──composer/composer 2.4.x-dev (requires composer/xdebug-handler ^2.0.2 || ^3.0.3)
│ └──composer/composer dev-main (requires composer/xdebug-handler ^2.0.2 || ^3.0.3)
└──symfony/console v5.4.11 (conflicts psr/log >=3) (circular dependency aborted here)
2016-01-11 08:52:25 +00:00
```
2012-02-19 14:16:25 +00:00
### Options
2016-02-15 00:11:24 +00:00
* **--recursive (-r):** Recursively resolves up to the root package.
* **--tree (-t):** Prints the results as a nested tree, implies -r.
2012-02-19 14:16:25 +00:00
2022-10-12 08:55:57 +00:00
## prohibits / why-not
2016-02-20 00:53:51 +00:00
The `prohibits` command tells you which packages are blocking a given package
from being installed. Specify a version constraint to verify whether upgrades
can be performed in your project, and if not why not. See the following
example:
2022-08-20 10:23:00 +00:00
```shell
2016-02-20 00:53:51 +00:00
php composer.phar prohibits symfony/symfony 3.1
2022-08-20 10:23:00 +00:00
```
```text
laravel/framework v5.2.16 requires symfony/var-dumper (2.8.*|3.0.*)
2014-05-19 10:17:07 +00:00
```
2012-02-19 14:16:25 +00:00
2016-02-20 00:53:51 +00:00
Note that you can also specify platform requirements, for example to check
whether you can upgrade your server to PHP 8.0:
2016-01-11 08:52:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2022-08-16 09:45:35 +00:00
php composer.phar prohibits php 8
2022-08-20 10:23:00 +00:00
```
```text
doctrine/cache v1.6.0 requires php (~5.5|~7.0)
doctrine/common v2.6.1 requires php (~5.5|~7.0)
doctrine/instantiator 1.0.5 requires php (>=5.3,< 8.0-DEV )
2016-01-11 08:52:25 +00:00
```
2016-02-20 00:53:51 +00:00
As with `depends` you can request a recursive lookup, which will list all
packages depending on the packages that cause the conflict.
2012-02-19 14:16:25 +00:00
### Options
2016-02-20 00:53:51 +00:00
* **--recursive (-r):** Recursively resolves up to the root package.
* **--tree (-t):** Prints the results as a nested tree, implies -r.
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
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar validate
```
2012-02-19 14:16:25 +00:00
2014-04-30 13:51:54 +00:00
### Options
2019-01-28 15:17:18 +00:00
* **--no-check-all:** Do not emit a warning if requirements in `composer.json` use unbound or overly strict version constraints.
2015-07-08 00:12:59 +00:00
* **--no-check-lock:** Do not emit an error if `composer.lock` exists and is not up to date.
2015-07-09 11:04:41 +00:00
* **--no-check-publish:** Do not emit an error if `composer.json` is unsuitable for publishing as a package on Packagist but is otherwise valid.
2017-03-21 13:57:46 +00:00
* **--with-dependencies:** Also validate the composer.json of all installed dependencies.
* **--strict:** Return a non-zero exit code for warnings as well as errors.
2015-07-09 11:04:41 +00:00
2012-11-30 16:23:01 +00:00
## status
If you often need to modify the code of your dependencies and they are
installed from source, the `status` command allows you to check if you have
local changes in any of them.
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar status
```
2012-11-30 16:23:01 +00:00
With the `--verbose` option you get some more information about what was
changed:
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar status -v
2022-08-20 10:23:00 +00:00
```
```text
2014-05-19 10:17:07 +00:00
You have changes in the following dependencies:
vendor/seld/jsonlint:
M README.mdown
```
2012-11-30 16:23:01 +00:00
2022-10-12 08:55:57 +00:00
## self-update / selfupdate
2012-02-19 14:16:25 +00:00
2018-03-23 10:37:33 +00:00
To update Composer itself to the latest version, run the `self-update`
2012-02-20 10:08:18 +00:00
command. It will replace your `composer.phar` with the latest version.
2012-02-19 14:16:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar self-update
```
2012-02-19 14:16:25 +00:00
2020-10-23 19:52:05 +00:00
If you would like to instead update to a specific release specify it:
2013-12-26 18:09:06 +00:00
2022-08-20 10:23:00 +00:00
```shell
php composer.phar self-update 2.4.0-RC1
2014-05-19 10:17:07 +00:00
```
2013-12-26 18:09:06 +00:00
2015-06-22 09:08:23 +00:00
If you have installed Composer for your entire system (see [global installation ](00-intro.md#globally )),
2013-12-26 18:09:06 +00:00
you may have to run the command with `root` privileges
2012-06-13 16:30:51 +00:00
2022-08-20 10:23:00 +00:00
```shell
2016-02-03 14:46:15 +00:00
sudo -H composer self-update
2014-05-19 10:17:07 +00:00
```
2012-06-13 16:30:51 +00:00
2020-10-26 12:03:24 +00:00
If Composer was not installed as a PHAR, this command is not available.
(This is sometimes the case when Composer was installed by an operating system package manager.)
2013-12-26 18:09:06 +00:00
### Options
* **--rollback (-r):** Rollback to the last version you had installed.
2015-06-24 06:43:07 +00:00
* **--clean-backups:** Delete old backups during an update. This makes the
2015-06-22 09:08:23 +00:00
current version of Composer the only backup available after the update.
2017-03-21 13:57:46 +00:00
* **--no-progress:** Do not output download progress.
* **--update-keys:** Prompt user for a key update.
* **--stable:** Force an update to the stable channel.
* **--preview:** Force an update to the preview channel.
* **--snapshot:** Force an update to the snapshot channel.
2020-11-04 15:35:20 +00:00
* **--1:** Force an update to the stable channel, but only use 1.x versions
* **--2:** Force an update to the stable channel, but only use 2.x versions
* **--set-channel-only:** Only store the channel as the default one and then exit
2013-12-26 18:09:06 +00:00
2012-12-07 03:30:44 +00:00
## config
2012-12-02 12:43:11 +00:00
2021-10-25 11:11:56 +00:00
The `config` command allows you to edit Composer config settings and repositories
2016-04-27 09:48:21 +00:00
in either the local `composer.json` file or the global `config.json` file.
Additionally it lets you edit most properties in the local `composer.json` .
2012-12-02 12:43:11 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar config --list
```
2012-12-02 12:43:11 +00:00
### Usage
`config [options] [setting-key] [setting-value1] ... [setting-valueN]`
`setting-key` is a configuration option name and `setting-value1` is a
configuration value. For settings that can take an array of values (like
2021-12-19 14:15:21 +00:00
`github-protocols` ), multiple setting-value arguments are allowed.
2012-12-02 12:43:11 +00:00
2016-04-27 09:48:21 +00:00
You can also edit the values of the following properties:
`description` , `homepage` , `keywords` , `license` , `minimum-stability` ,
`name` , `prefer-stable` , `type` and `version` .
2015-06-22 12:18:49 +00:00
See the [Config ](06-config.md ) chapter for valid configuration options.
2012-12-02 12:43:11 +00:00
### Options
2012-12-07 03:33:14 +00:00
* **--global (-g):** Operate on the global config file located at
2014-12-16 14:28:51 +00:00
`$COMPOSER_HOME/config.json` by default. Without this option, this command
affects the local composer.json file or a file specified by `--file` .
2012-12-07 03:33:14 +00:00
* **--editor (-e):** Open the local composer.json file using in a text editor as
2014-12-16 14:28:51 +00:00
defined by the `EDITOR` env variable. With the `--global` option, this opens
the global config file.
2017-03-21 13:57:46 +00:00
* **--auth (-a):** Affect auth config file (only used for --editor).
2012-12-02 12:43:11 +00:00
* **--unset:** Remove the configuration element named by `setting-key` .
2012-12-07 03:33:14 +00:00
* **--list (-l):** Show the list of current config variables. With the `--global`
2014-12-16 14:28:51 +00:00
option this lists the global configuration only.
2012-12-07 03:33:14 +00:00
* **--file="..." (-f):** Operate on a specific file instead of composer.json. Note
2014-12-16 14:28:51 +00:00
that this cannot be used in conjunction with the `--global` option.
2020-10-24 13:37:35 +00:00
* **--absolute:** Returns absolute paths when fetching `*-dir` config values
2014-12-16 14:28:51 +00:00
instead of relative.
2020-04-23 12:27:14 +00:00
* **--json:** JSON decode the setting value, to be used with `extra.*` keys.
* **--merge:** Merge the setting value with the current value, to be used with `extra.*` keys in combination with `--json` .
2021-11-11 14:17:58 +00:00
* **--append:** When adding a repository, append it (lowest priority) to the existing ones instead of prepending it (highest priority).
* **--source:** Display where the config value is loaded from.
2012-12-02 12:43:11 +00:00
### Modifying Repositories
In addition to modifying the config section, the `config` command also supports making
changes to the repositories section by using it the following way:
2022-08-20 10:23:00 +00:00
```shell
2015-05-04 17:37:57 +00:00
php composer.phar config repositories.foo vcs https://github.com/foo/bar
2014-05-19 10:17:07 +00:00
```
2012-12-02 12:43:11 +00:00
2016-01-22 10:08:00 +00:00
If your repository requires more configuration options, you can instead pass its JSON representation :
2022-08-20 10:23:00 +00:00
```shell
2016-01-22 10:08:00 +00:00
php composer.phar config repositories.foo '{"type": "vcs", "url": "http://svn.example.org/my-project/", "trunk-path": "master"}'
```
2016-04-27 09:48:21 +00:00
### Modifying Extra Values
In addition to modifying the config section, the `config` command also supports making
changes to the extra section by using it the following way:
2022-08-20 10:23:00 +00:00
```shell
2016-04-27 09:48:21 +00:00
php composer.phar config extra.foo.bar value
```
The dots indicate array nesting, a max depth of 3 levels is allowed though. The above
would set `"extra": { "foo": { "bar": "value" } }` .
2020-04-23 12:27:14 +00:00
If you have a complex value to add/modify, you can use the `--json` and `--merge` flags
to edit extra fields as json:
2022-08-20 10:23:00 +00:00
```shell
2020-04-23 12:27:14 +00:00
php composer.phar config --json extra.foo.bar '{"baz": true, "qux": []}'
```
2012-04-13 10:36:27 +00:00
## create-project
2012-11-08 14:44:41 +00:00
You can use Composer to create new projects from an existing package. This is
2017-12-29 11:44:51 +00:00
the equivalent of doing a git clone/svn checkout followed by a `composer install`
2012-11-08 14:44:41 +00:00
of the vendors.
2012-04-13 10:36:27 +00:00
There are several applications for this:
1. You can deploy application packages.
2. You can check out any package and start developing on patches for example.
3. Projects with multiple developers can use this feature to bootstrap the
initial application for development.
2017-12-29 11:44:51 +00:00
To create a new project using Composer you can use the `create-project` command.
2012-04-13 10:36:27 +00:00
Pass it a package name, and the directory to create the project in. You can also
2021-12-19 14:15:21 +00:00
provide a version as a third argument, otherwise the latest version is used.
2012-04-13 10:36:27 +00:00
2013-03-02 11:42:53 +00:00
If the directory does not currently exist, it will be created during installation.
2012-04-13 10:36:27 +00:00
2022-08-20 10:23:00 +00:00
```shell
2020-02-07 13:29:05 +00:00
php composer.phar create-project doctrine/orm path "2.2.*"
2014-05-19 10:17:07 +00:00
```
2012-04-13 10:36:27 +00:00
2013-05-31 09:39:14 +00:00
It is also possible to run the command without params in a directory with an
existing `composer.json` file to bootstrap a project.
2012-04-13 10:36:27 +00:00
By default the command checks for the packages on packagist.org.
### Options
2017-03-21 13:57:46 +00:00
* **--stability (-s):** Minimum stability of package. Defaults to `stable` .
2021-04-07 14:04:42 +00:00
* **--prefer-install:** There are two ways of downloading a package: `source`
and `dist` . Composer uses `dist` by default. If you pass
`--prefer-install=source` (or `--prefer-source` ) 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.
To get the legacy behavior where Composer use `source` automatically for dev
versions of packages, use `--prefer-install=auto` . See also [config.preferred-install ](06-config.md#preferred-install ).
Passing this flag will override the config value.
2016-02-29 17:32:32 +00:00
* **--repository:** Provide a custom repository to search for the package,
2012-04-13 10:36:27 +00:00
which will be used instead of packagist. Can be either an HTTP URL pointing
2016-02-29 17:32:32 +00:00
to a `composer` repository, a path to a local `packages.json` file, or a
JSON string which similar to what the [repositories ](04-schema.md#repositories )
2020-07-17 08:38:46 +00:00
key accepts. You can use this multiple times to configure multiple repositories.
* **--add-repository:** Add the custom repository in the composer.json. If a lock
2021-12-19 14:15:21 +00:00
file is present, it will be deleted and an update will be run instead of an install.
2012-05-30 21:55:04 +00:00
* **--dev:** Install packages listed in `require-dev` .
2017-03-21 13:57:46 +00:00
* **--no-dev:** Disables installation of require-dev packages.
2012-11-08 14:44:58 +00:00
* **--no-scripts:** Disables the execution of the scripts defined in the root
package.
2012-12-13 16:19:58 +00:00
* **--no-progress:** Removes the progress display that can mess with some
terminals or scripts which don't handle backspace characters.
2018-02-21 21:09:43 +00:00
* **--no-secure-http:** Disable the secure-http config option temporarily while
installing the root package. Use at your own risk. Using this flag is a bad
idea.
2012-11-08 14:44:58 +00:00
* **--keep-vcs:** Skip the deletion of the VCS metadata for the created
project. This is mostly useful if you run the command in non-interactive
mode.
2018-01-31 15:23:01 +00:00
* **--remove-vcs:** Force-remove the VCS metadata without prompting.
2017-03-21 13:57:46 +00:00
* **--no-install:** Disables installation of the vendors.
2022-08-17 09:44:18 +00:00
* **--no-audit:** Does not run the audit steps after installation is complete. Also see [COMPOSER_NO_AUDIT ](#composer-no-audit ).
2022-07-25 11:13:32 +00:00
* **--audit-format:** Audit output format. Must be "table", "plain", "json", or "summary" (default).
2020-06-02 09:17:49 +00:00
* **--ignore-platform-reqs:** ignore all platform requirements (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and force the installation even if the local machine does
not fulfill these.
2020-06-01 13:43:24 +00:00
See also the [`platform` ](06-config.md#platform ) config option.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-req:** ignore a specific platform requirement(`php`,
`hhvm` , `lib-*` and `ext-*` ) and force the installation even if the local machine
2021-11-11 14:56:38 +00:00
does not fulfill it. Multiple requirements can be ignored via wildcard.
2021-12-19 14:15:21 +00:00
* **--ask:** Ask the user to provide a target directory for the new project.
2012-04-13 10:36:27 +00:00
2022-10-12 08:55:57 +00:00
## dump-autoload / dumpautoload
2012-08-15 10:39:53 +00:00
If you need to update the autoloader because of new classes in a classmap
2017-12-29 11:44:51 +00:00
package for example, you can use `dump-autoload` to do that without having to
2012-08-15 10:39:53 +00:00
go through an install or update.
2014-01-03 15:46:56 +00:00
Additionally, it can dump an optimized autoloader that converts PSR-0/4 packages
2012-08-15 10:39:53 +00:00
into classmap ones for performance reasons. In large applications with many
classes, the autoloader can take up a substantial portion of every request's
time. Using classmaps for everything is less convenient in development, but
2014-01-03 15:46:56 +00:00
using this option you can still use PSR-0/4 for convenience and classmaps for
2012-08-15 10:39:53 +00:00
performance.
### Options
2014-01-03 15:46:56 +00:00
* **--optimize (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
2012-08-15 10:39:53 +00:00
autoloader. This is recommended especially for production, but can take
2020-06-30 15:39:56 +00:00
a bit of time to run, so it is currently not done by default.
2015-08-16 19:56:52 +00:00
* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
Implicitly enables `--optimize` .
2016-07-28 08:23:39 +00:00
* **--apcu:** Use APCu to cache found/not-found classes.
2020-10-13 08:22:46 +00:00
* **--apcu-prefix:** Use a custom prefix for the APCu autoloader cache.
Implicitly enables `--apcu` .
2021-05-25 20:39:55 +00:00
* **--no-dev:** Disables autoload-dev rules. Composer will by default infer this
automatically according to the last `install` or `update` `--no-dev` state.
2021-06-07 13:48:37 +00:00
* **--dev:** Enables autoload-dev rules. Composer will by default infer this
automatically according to the last `install` or `update` `--no-dev` state.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-reqs:** ignore all `php` , `hhvm` , `lib-*` and `ext-*`
2020-06-01 13:43:24 +00:00
requirements and skip the [platform check ](07-runtime.md#platform-check ) for these.
See also the [`platform` ](06-config.md#platform ) config option.
2020-06-02 09:17:49 +00:00
* **--ignore-platform-req:** ignore a specific platform requirement (`php`, `hhvm` ,
`lib-*` and `ext-*` ) and skip the [platform check ](07-runtime.md#platform-check ) for it.
2021-11-11 14:56:38 +00:00
Multiple requirements can be ignored via wildcard.
2023-07-21 12:47:54 +00:00
* **--strict-psr:** Return a failed exit code (1) if PSR-4 or PSR-0 mapping errors
2022-06-20 11:57:20 +00:00
are present. Requires --optimize to work.
2012-08-15 10:39:53 +00:00
2019-12-04 10:41:39 +00:00
## clear-cache / clearcache / cc
2014-12-13 17:59:14 +00:00
Deletes all content from Composer's cache directories.
2022-06-09 09:46:00 +00:00
### Options
* **--gc:** Only run garbage collection, not a full cache clear
2013-08-17 01:45:51 +00:00
## licenses
Lists the name, version and license of every package installed. Use
2020-06-30 15:39:56 +00:00
`--format=json` to get machine-readable output.
2013-08-17 01:45:51 +00:00
2014-12-08 21:21:33 +00:00
### Options
2020-06-16 08:07:53 +00:00
* **--format:** Format of the output: text, json or summary (default: "text")
2017-03-21 13:57:46 +00:00
* **--no-dev:** Remove dev dependencies from the output
2014-12-08 21:21:33 +00:00
2022-10-12 08:55:57 +00:00
## run-script / run
2013-05-04 08:46:10 +00:00
2015-02-03 14:26:02 +00:00
### Options
2016-02-15 19:47:43 +00:00
* **--timeout:** Set the script timeout in seconds, or 0 for no timeout.
2017-03-21 13:57:46 +00:00
* **--dev:** Sets the dev mode.
* **--no-dev:** Disable dev mode.
* **--list (-l):** List user defined scripts.
2015-02-03 14:26:02 +00:00
2013-05-04 08:46:10 +00:00
To run [scripts ](articles/scripts.md ) manually you can use this command,
2018-03-23 10:37:33 +00:00
give it the script name and optionally any required arguments.
2013-05-04 08:46:10 +00:00
2016-02-25 12:21:30 +00:00
## exec
Executes a vendored binary/script. You can execute any command and this will
ensure that the Composer bin-dir is pushed on your PATH before the command
runs.
### Options
2021-10-25 11:11:56 +00:00
* **--list (-l):** List the available Composer binaries.
2016-02-25 12:21:30 +00:00
2013-04-04 13:44:18 +00:00
## diagnose
2013-04-03 22:47:03 +00:00
If you think you found a bug, or something is behaving strangely, you might
2013-04-04 13:44:18 +00:00
want to run the `diagnose` command to perform automated checks for many common
2013-04-03 22:47:03 +00:00
problems.
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar diagnose
```
2013-04-03 22:47:03 +00:00
2013-12-27 10:26:01 +00:00
## archive
This command is used to generate a zip/tar archive for a given package in a
given version. It can also be used to archive your entire project without
excluded/ignored files.
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar archive vendor/package 2.0.21 --format=zip
```
2013-12-27 10:26:01 +00:00
### Options
2021-12-07 14:56:35 +00:00
* **--format (-f):** Format of the resulting archive: tar, tar.gz, tar.bz2
or zip (default: "tar").
2013-12-27 10:26:01 +00:00
* **--dir:** Write the archive to this directory (default: ".")
2017-03-21 13:57:46 +00:00
* **--file:** Write the archive with the given file name.
2013-12-27 10:26:01 +00:00
2022-06-22 13:14:00 +00:00
## audit
This command is used to audit the packages you have installed
2022-06-23 10:59:45 +00:00
for possible security issues. It checks for and
2022-06-22 13:14:00 +00:00
lists security vulnerability advisories according to the
[Packagist.org api ](https://packagist.org/apidoc#list-security-advisories ).
2022-10-13 08:53:26 +00:00
The audit command returns the amount of vulnerabilities found. `0` if successful, and up to `255` otherwise.
2022-08-20 10:23:00 +00:00
```shell
2022-06-22 13:14:00 +00:00
php composer.phar audit
```
### Options
* **--no-dev:** Disables auditing of require-dev packages.
2022-07-25 11:13:32 +00:00
* **--format (-f):** Audit output format. Must be "table" (default), "plain", "json", or "summary".
2022-06-22 13:14:00 +00:00
* **--locked:** Audit packages from the lock file, regardless of what is currently in vendor dir.
2024-09-17 13:44:55 +00:00
* **--abandoned:** Behavior on abandoned packages. Must be "ignore", "report",
or "fail". See also [audit.abandoned ](06-config.md#abandoned ). Passing this
flag will override the config value and the environment variable.
2022-06-22 13:14:00 +00:00
2012-02-19 14:16:25 +00:00
## help
2018-03-23 10:37:33 +00:00
To get more information about a certain command, you can use `help` .
2012-02-19 14:16:25 +00:00
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
php composer.phar help install
```
2012-02-26 11:40:35 +00:00
2016-01-10 11:17:04 +00:00
## Command-line completion
2024-09-17 09:07:27 +00:00
Command-line completion can be enabled by running the `composer completion --help` command and
following the instructions.
2016-01-10 11:17:04 +00:00
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`
2013-08-14 13:37:09 +00:00
section of `composer.json` instead. It is worth noting that the env vars will
always take precedence over the values specified in `composer.json` .
2012-02-26 11:40:35 +00:00
### COMPOSER
2012-03-17 14:02:39 +00:00
By setting the `COMPOSER` env variable it is possible to set the filename of
2012-02-26 11:40:35 +00:00
`composer.json` to something else.
For example:
2022-08-20 10:23:00 +00:00
```shell
2014-05-19 10:17:07 +00:00
COMPOSER=composer-other.json php composer.phar install
```
2012-02-26 11:40:35 +00:00
2015-07-16 09:51:31 +00:00
The generated lock file will use the same name: `composer-other.lock` in this example.
2018-12-24 09:45:06 +00:00
### COMPOSER_ALLOW_SUPERUSER
2012-05-24 18:36:47 +00:00
2018-12-24 09:45:06 +00:00
If set to 1, this env disables the warning about running commands as root/super user.
It also disables automatic clearing of sudo sessions, so you should really only set this
2021-12-19 14:15:21 +00:00
if you use Composer as a super user at all times like in docker containers.
2012-05-24 18:36:47 +00:00
2019-11-03 13:23:09 +00:00
### COMPOSER_ALLOW_XDEBUG
If set to 1, this env allows running Composer when the Xdebug extension is enabled, without restarting PHP without it.
2018-12-24 09:45:06 +00:00
### COMPOSER_AUTH
2012-02-26 11:40:35 +00:00
2018-12-24 09:45:06 +00:00
The `COMPOSER_AUTH` var allows you to set up authentication as an environment variable.
2020-10-13 21:30:47 +00:00
The contents of the variable should be a JSON formatted object containing [http-basic,
github-oauth, bitbucket-oauth, ... objects as needed](articles/authentication-for-private-packages.md),
and following the
[spec from the config ](06-config.md ).
2012-02-26 11:40:35 +00:00
### COMPOSER_BIN_DIR
2013-01-14 18:42:12 +00:00
By setting this option you can change the `bin` ([Vendor Binaries](articles/vendor-binaries.md))
2012-02-26 11:40:35 +00:00
directory to something other than `vendor/bin` .
2018-12-24 09:45:06 +00:00
### COMPOSER_CACHE_DIR
2013-06-20 19:03:00 +00:00
2018-12-24 09:45:06 +00:00
The `COMPOSER_CACHE_DIR` var allows you to change the Composer cache directory,
which is also configurable via the [`cache-dir` ](06-config.md#cache-dir ) option.
2013-06-20 19:03:00 +00:00
2021-12-07 00:54:03 +00:00
By default, it points to `C:\Users\<user>\AppData\Local\Composer` (or `%LOCALAPPDATA%/Composer` ) on Windows.
On \*nix systems that follow the [XDG Base
Directory Specifications](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html),
it points to `$XDG_CACHE_HOME/composer` . On other \*nix systems and on macOS, it points to
`$COMPOSER_HOME/cache` .
2013-06-20 19:03:00 +00:00
2018-12-24 09:45:06 +00:00
### COMPOSER_CAFILE
2013-04-25 15:18:58 +00:00
2018-12-24 09:45:06 +00:00
By setting this environmental value, you can set a path to a certificate bundle
file to be used during SSL/TLS peer verification.
2013-04-25 15:18:58 +00:00
2019-11-03 13:23:09 +00:00
### COMPOSER_DISABLE_XDEBUG_WARN
If set to 1, this env suppresses a warning when Composer is running with the Xdebug extension enabled.
2018-12-24 09:45:06 +00:00
### COMPOSER_DISCARD_CHANGES
2013-05-30 12:58:26 +00:00
2018-12-24 09:45:06 +00:00
This env var controls the [`discard-changes` ](06-config.md#discard-changes ) config option.
2013-05-30 12:58:26 +00:00
2024-01-08 14:10:49 +00:00
### COMPOSER_FUND
If set to 0, this env suppresses funding notices when installing.
2012-04-26 15:24:31 +00:00
### COMPOSER_HOME
2015-06-22 09:08:23 +00:00
The `COMPOSER_HOME` var allows you to change the Composer home directory. This
2012-04-26 16:54:45 +00:00
is a hidden, global (per-user on the machine) directory that is shared between
all projects.
2012-04-26 15:24:31 +00:00
2021-01-12 15:19:29 +00:00
Use `composer config --global home` to see the location of the home directory.
2020-06-30 15:39:56 +00:00
By default, it points to `C:\Users\<user>\AppData\Roaming\Composer` on Windows
2018-10-31 17:13:39 +00:00
and `/Users/<user>/.composer` on macOS. On \*nix systems that follow the [XDG Base
2017-12-29 10:33:19 +00:00
Directory Specifications](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html),
2018-09-26 13:12:25 +00:00
it points to `$XDG_CONFIG_HOME/composer` . On other \*nix systems, it points to
2013-01-02 12:48:00 +00:00
`/home/<user>/.composer` .
2012-04-26 15:24:31 +00:00
2012-08-13 14:26:24 +00:00
#### COMPOSER_HOME/config.json
You may put a `config.json` file into the location which `COMPOSER_HOME` points
2021-10-13 20:45:15 +00:00
to. Composer will partially (only `config` and `repositories` keys) merge this
configuration with your project's `composer.json` when you run the `install` and
`update` commands.
2012-08-13 14:26:24 +00:00
2015-06-22 12:18:49 +00:00
This file allows you to set [repositories ](05-repositories.md ) and
[configuration ](06-config.md ) for the user's projects.
2012-08-13 14:26:24 +00:00
In case global configuration matches _local_ configuration, the _local_
configuration in the project's `composer.json` always wins.
2018-12-24 09:45:06 +00:00
### COMPOSER_HTACCESS_PROTECT
2013-08-13 13:19:08 +00:00
2018-12-24 09:45:06 +00:00
Defaults to `1` . If set to `0` , Composer will not create `.htaccess` files in the
2021-10-25 11:11:56 +00:00
Composer home, cache, and data directories.
2013-08-13 13:19:08 +00:00
2018-12-24 09:45:06 +00:00
### COMPOSER_MEMORY_LIMIT
If set, the value is used as php's memory_limit.
### COMPOSER_MIRROR_PATH_REPOS
If set to 1, this env changes the default path repository strategy to `mirror` instead
of `symlink` . As it is the default strategy being set it can still be overwritten by
repository options.
### COMPOSER_NO_INTERACTION
If set to 1, this env var will make Composer behave as if you passed the
`--no-interaction` flag to every command. This can be set on build boxes/CI.
2013-08-13 13:19:08 +00:00
2012-04-26 15:24:31 +00:00
### COMPOSER_PROCESS_TIMEOUT
2015-06-22 09:08:23 +00:00
This env var controls the time Composer waits for commands (such as git
2012-04-26 16:59:09 +00:00
commands) to finish executing. The default value is 300 seconds (5 minutes).
2012-04-26 15:24:31 +00:00
2018-12-24 09:45:06 +00:00
### COMPOSER_ROOT_VERSION
2014-03-02 18:24:03 +00:00
2020-07-17 08:38:46 +00:00
By setting this var you can specify the version of the root package, if it
2020-06-30 15:39:56 +00:00
cannot be guessed from VCS info and is not present in `composer.json` .
2016-01-26 19:09:44 +00:00
2018-12-24 09:45:06 +00:00
### COMPOSER_VENDOR_DIR
2016-01-26 19:09:44 +00:00
2018-12-24 09:45:06 +00:00
By setting this var you can make Composer install the dependencies into a
directory other than `vendor` .
2013-04-10 16:31:10 +00:00
2021-04-01 07:48:07 +00:00
### COMPOSER_RUNTIME_ENV
This lets you hint under which environment Composer is running, which can help Composer
work around some environment specific issues. The only value currently supported is
`virtualbox` , which then enables some short `sleep()` calls to wait for the filesystem
to have written files properly before we attempt reading them. You can set the
environment variable if you use Vagrant or VirtualBox and experience issues with files not
being found during installation even though they should be present.
2018-12-24 09:45:06 +00:00
### http_proxy or HTTP_PROXY
2024-04-19 15:27:54 +00:00
### HTTP_PROXY_REQUEST_FULLURI
### HTTPS_PROXY_REQUEST_FULLURI
### no_proxy or NO_PROXY
2013-04-10 16:31:10 +00:00
2024-04-19 15:27:54 +00:00
See the [proxy documentation ](faqs/how-to-use-composer-behind-a-proxy.md ) for more details
on how to use proxy env vars.
2016-04-01 11:31:07 +00:00
2024-02-07 21:13:36 +00:00
### COMPOSER_AUDIT_ABANDONED
Set to `ignore` , `report` or `fail` to override the [audit.abandoned ](06-config.md#abandoned )
config option.
2021-02-10 13:34:59 +00:00
### COMPOSER_MAX_PARALLEL_HTTP
Set to an integer to configure how many files can be downloaded in parallel. This
defaults to 12 and must be between 1 and 50. If your proxy has issues with
concurrency maybe you want to lower this. Increasing it should generally not result
in performance gains.
2024-01-11 16:13:54 +00:00
### COMPOSER_IPRESOLVE
Set to `4` or `6` to force IPv4 or IPv6 DNS resolution. This only works when the
curl extension is used for downloads.
2019-06-07 14:49:07 +00:00
### COMPOSER_SELF_UPDATE_TARGET
2021-12-19 14:15:21 +00:00
If set, makes the self-update command write the new Composer phar file into that path instead of overwriting itself. Useful for updating Composer on a read-only filesystem.
2019-06-07 14:49:07 +00:00
2018-12-04 10:36:15 +00:00
### COMPOSER_DISABLE_NETWORK
If set to `1` , disables network access (best effort). This can be used for debugging or
to run Composer on a plane or a starship with poor connectivity.
2020-06-30 15:39:56 +00:00
If set to `prime` , GitHub VCS repositories will prime the cache, so it can then be used
2020-04-08 15:53:15 +00:00
fully offline with `1` .
2020-10-13 10:05:24 +00:00
### COMPOSER_DEBUG_EVENTS
If set to `1` , outputs information about events being dispatched, which can be
useful for plugin authors to identify what is firing when exactly.
2022-08-17 09:44:18 +00:00
### COMPOSER_NO_AUDIT
If set to `1` , it is the equivalent of passing the `--no-audit` option to `require` , `update` , `remove` or `create-project` command.
2021-11-24 10:32:19 +00:00
### COMPOSER_NO_DEV
2023-05-02 20:44:29 +00:00
If set to `1` , it is the equivalent of passing the `--update-no-dev` option to `require`
or the `--no-dev` option to `install` or `update` . You can override this for a single
command by setting `COMPOSER_NO_DEV=0` .
2022-03-15 14:29:25 +00:00
2022-07-20 20:29:27 +00:00
### COMPOSER_PREFER_STABLE
If set to `1` , it is the equivalent of passing the `--prefer-stable` option to
`update` or `require` .
### COMPOSER_PREFER_LOWEST
If set to `1` , it is the equivalent of passing the `--prefer-lowest` option to
`update` or `require` .
2023-10-26 08:25:04 +00:00
### COMPOSER_MINIMAL_CHANGES
If set to `1` , it is the equivalent of passing the `--minimal-changes` option to
`update` , `require` or `remove` .
2022-03-15 14:29:25 +00:00
### COMPOSER_IGNORE_PLATFORM_REQ or COMPOSER_IGNORE_PLATFORM_REQS
If `COMPOSER_IGNORE_PLATFORM_REQS` set to `1` , it is the equivalent of passing the `--ignore-platform-reqs` argument.
Otherwise, specifying a comma separated list in `COMPOSER_IGNORE_PLATFORM_REQ` will ignore those specific requirements.
2022-05-12 08:24:53 +00:00
For example, if a development workstation will never run database queries, this can be used to ignore the requirement for the database extensions to be available. If you set `COMPOSER_IGNORE_PLATFORM_REQ=ext-oci8` , then composer will allow packages to be installed even if the `oci8` PHP extension is not enabled.
← [Libraries ](02-libraries.md ) | [Schema ](04-schema.md ) →