1# Command-line interface / Commands
2
3You've already learned how to use the command-line interface to do some
4things. This chapter documents all the available commands.
5
6To get help from the command-line, simply call `composer` or `composer list`
7to see the complete list of commands, then `--help` combined with any of those
8can give you more information.
9
10## Global Options
11
12The following options are available with every command:
13
14* **--verbose (-v):** Increase verbosity of messages.
15* **--help (-h):** Display help information.
16* **--quiet (-q):** Do not output any message.
17* **--no-interaction (-n):** Do not ask any interactive question.
18* **--no-plugins:** Disables plugins.
19* **--working-dir (-d):** If specified, use the given directory as working directory.
20* **--profile:** Display timing and memory usage information
21* **--ansi:** Force ANSI output.
22* **--no-ansi:** Disable ANSI output.
23* **--version (-V):** Display this application version.
24
25## Process Exit Codes
26
27* **0:** OK
28* **1:** Generic/unknown error code
29* **2:** Dependency solving error code
30
31## init
32
33In the [Libraries](02-libraries.md) chapter we looked at how to create a
34`composer.json` by hand. There is also an `init` command available that makes
35it a bit easier to do this.
36
37When you run the command it will interactively ask you to fill in the fields,
38while using some smart defaults.
39
40```sh
41php composer.phar init
42```
43
44### Options
45
46* **--name:** Name of the package.
47* **--description:** Description of the package.
48* **--author:** Author name of the package.
49* **--homepage:** Homepage of the package.
50* **--require:** Package to require with a version constraint. Should be
51  in format `foo/bar:1.0.0`.
52* **--require-dev:** Development requirements, see **--require**.
53* **--stability (-s):** Value for the `minimum-stability` field.
54* **--repository:** Provide one (or more) custom repositories. They will be stored
55  in the generated composer.json, and used for auto-completion when prompting for
56  the list of requires. Every repository can be either an HTTP URL pointing
57  to a `composer` repository or a JSON string which similar to what the
58  [repositories](04-schema.md#repositories) key accepts.
59
60## install
61
62The `install` command reads the `composer.json` file from the current
63directory, resolves the dependencies, and installs them into `vendor`.
64
65```sh
66php composer.phar install
67```
68
69If there is a `composer.lock` file in the current directory, it will use the
70exact versions from there instead of resolving them. This ensures that
71everyone using the library will get the same versions of the dependencies.
72
73If there is no `composer.lock` file, Composer will create one after dependency
74resolution.
75
76### Options
77
78* **--prefer-source:** There are two ways of downloading a package: `source`
79  and `dist`. For stable versions Composer will use the `dist` by default.
80  The `source` is a version control repository. If `--prefer-source` is
81  enabled, Composer will install from `source` if there is one. This is
82  useful if you want to make a bugfix to a project and get a local git
83  clone of the dependency directly.
84* **--prefer-dist:** Reverse of `--prefer-source`, Composer will install
85  from `dist` if possible. This can speed up installs substantially on build
86  servers and other use cases where you typically do not run updates of the
87  vendors. It is also a way to circumvent problems with git if you do not
88  have a proper setup.
89* **--ignore-platform-reqs:** ignore `php`, `hhvm`, `lib-*` and `ext-*`
90  requirements and force the installation even if the local machine does not
91  fulfill these. See also the [`platform`](06-config.md#platform) config option.
92* **--dry-run:** If you want to run through an installation without actually
93  installing a package, you can use `--dry-run`. This will simulate the
94  installation and show you what would happen.
95* **--dev:** Install packages listed in `require-dev` (this is the default behavior).
96* **--no-dev:** Skip installing packages listed in `require-dev`. The autoloader
97  generation skips the `autoload-dev` rules.
98* **--no-autoloader:** Skips autoloader generation.
99* **--no-scripts:** Skips execution of scripts defined in `composer.json`.
100* **--no-progress:** Removes the progress display that can mess with some
101  terminals or scripts which don't handle backspace characters.
102* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
103  autoloader. This is recommended especially for production, but can take
104  a bit of time to run so it is currently not done by default.
105* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
106  Implicitly enables `--optimize-autoloader`.
107
108## update
109
110In order to get the latest versions of the dependencies and to update the
111`composer.lock` file, you should use the `update` command.
112
113```sh
114php composer.phar update
115```
116
117This will resolve all dependencies of the project and write the exact versions
118into `composer.lock`.
119
120If you just want to update a few packages and not all, you can list them as such:
121
122```sh
123php composer.phar update vendor/package vendor/package2
124```
125
126You can also use wildcards to update a bunch of packages at once:
127
128```sh
129php composer.phar update vendor/*
130```
131
132### Options
133
134* **--prefer-source:** Install packages from `source` when available.
135* **--prefer-dist:** Install packages from `dist` when available.
136* **--ignore-platform-reqs:** ignore `php`, `hhvm`, `lib-*` and `ext-*`
137  requirements and force the installation even if the local machine does not
138  fulfill these. See also the [`platform`](06-config.md#platform) config option.
139* **--dry-run:** Simulate the command without actually doing anything.
140* **--dev:** Install packages listed in `require-dev` (this is the default behavior).
141* **--no-dev:** Skip installing packages listed in `require-dev`. The autoloader generation skips the `autoload-dev` rules.
142* **--no-autoloader:** Skips autoloader generation.
143* **--no-scripts:** Skips execution of scripts defined in `composer.json`.
144* **--no-progress:** Removes the progress display that can mess with some
145  terminals or scripts which don't handle backspace characters.
146* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
147  autoloader. This is recommended especially for production, but can take
148  a bit of time to run so it is currently not done by default.
149* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
150  Implicitly enables `--optimize-autoloader`.
151* **--lock:** Only updates the lock file hash to suppress warning about the
152  lock file being out of date.
153* **--with-dependencies:** Add also all dependencies of whitelisted packages to the whitelist.
154* **--root-reqs:** Restricts the update to your first degree dependencies.
155* **--prefer-stable:** Prefer stable versions of dependencies.
156* **--prefer-lowest:** Prefer lowest versions of dependencies. Useful for testing minimal
157  versions of requirements, generally used with `--prefer-stable`.
158
159## require
160
161The `require` command adds new packages to the `composer.json` file from
162the current directory. If no file exists one will be created on the fly.
163
164```sh
165php composer.phar require
166```
167
168After adding/changing the requirements, the modified requirements will be
169installed or updated.
170
171If you do not want to choose requirements interactively, you can just pass them
172to the command.
173
174```sh
175php composer.phar require vendor/package:2.* vendor/package2:dev-master
176```
177
178### Options
179
180* **--prefer-source:** Install packages from `source` when available.
181* **--prefer-dist:** Install packages from `dist` when available.
182* **--ignore-platform-reqs:** ignore `php`, `hhvm`, `lib-*` and `ext-*`
183  requirements and force the installation even if the local machine does not
184  fulfill these. See also the [`platform`](06-config.md#platform) config option.
185* **--dev:** Add packages to `require-dev`.
186* **--no-update:** Disables the automatic update of the dependencies.
187* **--no-progress:** Removes the progress display that can mess with some
188  terminals or scripts which don't handle backspace characters.
189* **--no-scripts:** Skips execution of scripts defined in `composer.json`.
190* **--update-no-dev:** Run the dependency update with the `--no-dev` option.
191* **--update-with-dependencies:** Also update dependencies of the newly
192  required packages.
193* **--sort-packages:** Keep packages sorted in `composer.json`.
194* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to
195  get a faster autoloader. This is recommended especially for production, but
196  can take a bit of time to run so it is currently not done by default.
197* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
198  Implicitly enables `--optimize-autoloader`.
199* **--prefer-stable:** Prefer stable versions of dependencies.
200* **--prefer-lowest:** Prefer lowest versions of dependencies. Useful for testing minimal
201  versions of requirements, generally used with `--prefer-stable`.
202
203## remove
204
205The `remove` command removes packages from the `composer.json` file from
206the current directory.
207
208```sh
209php composer.phar remove vendor/package vendor/package2
210```
211
212After removing the requirements, the modified requirements will be
213uninstalled.
214
215### Options
216* **--ignore-platform-reqs:** ignore `php`, `hhvm`, `lib-*` and `ext-*`
217  requirements and force the installation even if the local machine does not
218  fulfill these. See also the [`platform`](06-config.md#platform) config option.
219* **--dev:** Remove packages from `require-dev`.
220* **--no-update:** Disables the automatic update of the dependencies.
221* **--no-progress:** Removes the progress display that can mess with some
222  terminals or scripts which don't handle backspace characters.
223* **--no-scripts:** Skips execution of scripts defined in `composer.json`.
224* **--update-no-dev:** Run the dependency update with the --no-dev option.
225* **--update-with-dependencies:** Also update dependencies of the removed packages.
226* **--optimize-autoloader (-o):** Convert PSR-0/4 autoloading to classmap to
227  get a faster autoloader. This is recommended especially for production, but
228  can take a bit of time to run so it is currently not done by default.
229* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
230  Implicitly enables `--optimize-autoloader`.
231
232## global
233
234The global command allows you to run other commands like `install`, `require`
235or `update` as if you were running them from the [COMPOSER_HOME](#composer-home)
236directory.
237
238This is merely a helper to manage a project stored in a central location that
239can hold CLI tools or Composer plugins that you want to have available everywhere.
240
241This can be used to install CLI utilities globally. Here is an example:
242
243```sh
244php composer.phar global require fabpot/php-cs-fixer
245```
246
247Now the `php-cs-fixer` binary is available globally. Just make sure your global
248[vendor binaries](articles/vendor-binaries.md) directory is in your `$PATH`
249environment variable, you can get its location with the following command :
250
251```sh
252php composer.phar global config bin-dir --absolute
253```
254
255If you wish to update the binary later on you can just run a global update:
256
257```sh
258php composer.phar global update
259```
260
261## search
262
263The search command allows you to search through the current project's package
264repositories. Usually this will be just packagist. You simply pass it the
265terms you want to search for.
266
267```sh
268php composer.phar search monolog
269```
270
271You can also search for more than one term by passing multiple arguments.
272
273### Options
274
275* **--only-name (-N):** Search only in name.
276
277## show
278
279To list all of the available packages, you can use the `show` command.
280
281```sh
282php composer.phar show
283```
284
285To filter the list you can pass a package mask using wildcards.
286
287```sh
288php composer.phar show monolog/*
289
290monolog/monolog 1.19.0 Sends your logs to files, sockets, inboxes, databases and various web services
291```
292
293If you want to see the details of a certain package, you can pass the package
294name.
295
296```sh
297php composer.phar show monolog/monolog
298
299name     : monolog/monolog
300versions : master-dev, 1.0.2, 1.0.1, 1.0.0, 1.0.0-RC1
301type     : library
302names    : monolog/monolog
303source   : [git] https://github.com/Seldaek/monolog.git 3d4e60d0cbc4b888fe5ad223d77964428b1978da
304dist     : [zip] https://github.com/Seldaek/monolog/zipball/3d4e60d0cbc4b888fe5ad223d77964428b1978da 3d4e60d0cbc4b888fe5ad223d77964428b1978da
305license  : MIT
306
307autoload
308psr-0
309Monolog : src/
310
311requires
312php >=5.3.0
313```
314
315You can even pass the package version, which will tell you the details of that
316specific version.
317
318```sh
319php composer.phar show monolog/monolog 1.0.2
320```
321
322### Options
323
324* **--latest (-l):** List all installed packages including their latest version.
325* **--all (-a):** List all packages available in all your repositories.
326* **--installed (-i):** List the packages that are installed (this is enabled by default, and deprecated).
327* **--platform (-p):** List only platform packages (php & extensions).
328* **--self (-s):** List the root package info.
329* **--tree (-t):** List your dependencies as a tree. If you pass a package name it will show the dependency tree for that package.
330* **--name-only (-N):** List package names only.
331* **--path (-P):** List package paths.
332* **--outdated (-o):** Implies --latest, but this lists *only* packages that have a newer version available.
333* **--direct (-D):** Restricts the list of packages to your direct dependencies.
334
335## outdated
336
337The `outdated` command shows a list of installed packages that have updates available,
338including their current and latest versions. This is basically an alias for
339`composer show -lo`.
340
341The color coding is as such:
342
343- **green**: Dependency is in the latest version and is up to date.
344- **yellow**: Dependency has a new version available that includes backwards compatibility breaks according to semver, so upgrade when
345  you can but it may involve work.
346- **red**: Dependency has a new version that is semver-compatible and you should upgrade it.
347
348### Options
349
350* **--all (-a):** Show all packages, not just outdated (alias for `composer show -l`).
351* **--direct (-D):** Restricts the list of packages to your direct dependencies.
352
353## browse / home
354
355The `browse` (aliased to `home`) opens a package's repository URL or homepage
356in your browser.
357
358### Options
359
360* **--homepage (-H):** Open the homepage instead of the repository URL.
361
362## suggests
363
364Lists all packages suggested by currently installed set of packages. You can
365optionally pass one or multiple package names in the format of `vendor/package`
366to limit output to suggestions made by those packages only.
367
368Use the `--by-package` or `--by-suggestion` flags to group the output by
369the package offering the suggestions or the suggested packages respectively.
370
371### Options
372
373* **--by-package:** Groups output by suggesting package.
374* **--by-suggestion:** Groups output by suggested package.
375* **--no-dev:** Excludes suggestions from `require-dev` packages.
376* **--verbose (-v):** Increased verbosity adds suggesting package name and
377  reason for suggestion.
378
379## depends
380
381The `depends` command tells you which other packages depend on a certain
382package. As with installation `require-dev` relationships are only considered
383for the root package.
384
385```sh
386php composer.phar depends doctrine/lexer
387 doctrine/annotations v1.2.7 requires doctrine/lexer (1.*)
388 doctrine/common      v2.6.1 requires doctrine/lexer (1.*)
389```
390
391You can optionally specify a version constraint after the package to limit the
392search.
393
394Add the `--tree` or `-t` flag to show a recursive tree of why the package is
395depended upon, for example:
396
397```sh
398php composer.phar depends psr/log -t
399psr/log 1.0.0 Common interface for logging libraries
400|- aboutyou/app-sdk 2.6.11 (requires psr/log 1.0.*)
401|  `- __root__ (requires aboutyou/app-sdk ^2.6)
402|- monolog/monolog 1.17.2 (requires psr/log ~1.0)
403|  `- laravel/framework v5.2.16 (requires monolog/monolog ~1.11)
404|     `- __root__ (requires laravel/framework ^5.2)
405`- symfony/symfony v3.0.2 (requires psr/log ~1.0)
406   `- __root__ (requires symfony/symfony ^3.0)
407```
408
409### Options
410
411* **--recursive (-r):** Recursively resolves up to the root package.
412* **--tree (-t):** Prints the results as a nested tree, implies -r.
413
414## prohibits
415
416The `prohibits` command tells you which packages are blocking a given package
417from being installed. Specify a version constraint to verify whether upgrades
418can be performed in your project, and if not why not. See the following
419example:
420
421```sh
422php composer.phar prohibits symfony/symfony 3.1
423 laravel/framework v5.2.16 requires symfony/var-dumper (2.8.*|3.0.*)
424```
425
426Note that you can also specify platform requirements, for example to check
427whether you can upgrade your server to PHP 8.0:
428
429```sh
430php composer.phar prohibits php:8
431 doctrine/cache        v1.6.0 requires php (~5.5|~7.0)
432 doctrine/common       v2.6.1 requires php (~5.5|~7.0)
433 doctrine/instantiator 1.0.5  requires php (>=5.3,<8.0-DEV)
434```
435
436As with `depends` you can request a recursive lookup, which will list all
437packages depending on the packages that cause the conflict.
438
439### Options
440
441* **--recursive (-r):** Recursively resolves up to the root package.
442* **--tree (-t):** Prints the results as a nested tree, implies -r.
443
444## validate
445
446You should always run the `validate` command before you commit your
447`composer.json` file, and before you tag a release. It will check if your
448`composer.json` is valid.
449
450```sh
451php composer.phar validate
452```
453
454### Options
455
456* **--no-check-all:** Do not emit a warning if requirements in `composer.json` use unbound version constraints.
457* **--no-check-lock:** Do not emit an error if `composer.lock` exists and is not up to date.
458* **--no-check-publish:** Do not emit an error if `composer.json` is unsuitable for publishing as a package on Packagist but is otherwise valid.
459
460## status
461
462If you often need to modify the code of your dependencies and they are
463installed from source, the `status` command allows you to check if you have
464local changes in any of them.
465
466```sh
467php composer.phar status
468```
469
470With the `--verbose` option you get some more information about what was
471changed:
472
473```sh
474php composer.phar status -v
475
476You have changes in the following dependencies:
477vendor/seld/jsonlint:
478    M README.mdown
479```
480
481## self-update
482
483To update Composer itself to the latest version, just run the `self-update`
484command. It will replace your `composer.phar` with the latest version.
485
486```sh
487php composer.phar self-update
488```
489
490If you would like to instead update to a specific release simply specify it:
491
492```sh
493php composer.phar self-update 1.0.0-alpha7
494```
495
496If you have installed Composer for your entire system (see [global installation](00-intro.md#globally)),
497you may have to run the command with `root` privileges
498
499```sh
500sudo -H composer self-update
501```
502
503### Options
504
505* **--rollback (-r):** Rollback to the last version you had installed.
506* **--clean-backups:** Delete old backups during an update. This makes the
507  current version of Composer the only backup available after the update.
508
509## config
510
511The `config` command allows you to edit composer config settings and repositories
512in either the local `composer.json` file or the global `config.json` file.
513
514Additionally it lets you edit most properties in the local `composer.json`.
515
516```sh
517php composer.phar config --list
518```
519
520### Usage
521
522`config [options] [setting-key] [setting-value1] ... [setting-valueN]`
523
524`setting-key` is a configuration option name and `setting-value1` is a
525configuration value.  For settings that can take an array of values (like
526`github-protocols`), more than one setting-value arguments are allowed.
527
528You can also edit the values of the following properties:
529
530`description`, `homepage`, `keywords`, `license`, `minimum-stability`,
531`name`, `prefer-stable`, `type` and `version`.
532
533See the [Config](06-config.md) chapter for valid configuration options.
534
535### Options
536
537* **--global (-g):** Operate on the global config file located at
538  `$COMPOSER_HOME/config.json` by default.  Without this option, this command
539  affects the local composer.json file or a file specified by `--file`.
540* **--editor (-e):** Open the local composer.json file using in a text editor as
541  defined by the `EDITOR` env variable.  With the `--global` option, this opens
542  the global config file.
543* **--unset:** Remove the configuration element named by `setting-key`.
544* **--list (-l):** Show the list of current config variables.  With the `--global`
545  option this lists the global configuration only.
546* **--file="..." (-f):** Operate on a specific file instead of composer.json. Note
547  that this cannot be used in conjunction with the `--global` option.
548* **--absolute:** Returns absolute paths when fetching *-dir config values
549  instead of relative.
550
551### Modifying Repositories
552
553In addition to modifying the config section, the `config` command also supports making
554changes to the repositories section by using it the following way:
555
556```sh
557php composer.phar config repositories.foo vcs https://github.com/foo/bar
558```
559
560If your repository requires more configuration options, you can instead pass its JSON representation :
561
562```sh
563php composer.phar config repositories.foo '{"type": "vcs", "url": "http://svn.example.org/my-project/", "trunk-path": "master"}'
564```
565
566### Modifying Extra Values
567
568In addition to modifying the config section, the `config` command also supports making
569changes to the extra section by using it the following way:
570
571```sh
572php composer.phar config extra.foo.bar value
573```
574
575The dots indicate array nesting, a max depth of 3 levels is allowed though. The above
576would set `"extra": { "foo": { "bar": "value" } }`.
577
578## create-project
579
580You can use Composer to create new projects from an existing package. This is
581the equivalent of doing a git clone/svn checkout followed by a "composer install"
582of the vendors.
583
584There are several applications for this:
585
5861. You can deploy application packages.
5872. You can check out any package and start developing on patches for example.
5883. Projects with multiple developers can use this feature to bootstrap the
589   initial application for development.
590
591To create a new project using Composer you can use the "create-project" command.
592Pass it a package name, and the directory to create the project in. You can also
593provide a version as third argument, otherwise the latest version is used.
594
595If the directory does not currently exist, it will be created during installation.
596
597```sh
598php composer.phar create-project doctrine/orm path 2.2.*
599```
600
601It is also possible to run the command without params in a directory with an
602existing `composer.json` file to bootstrap a project.
603
604By default the command checks for the packages on packagist.org.
605
606### Options
607
608* **--repository:** Provide a custom repository to search for the package,
609  which will be used instead of packagist. Can be either an HTTP URL pointing
610  to a `composer` repository, a path to a local `packages.json` file, or a
611  JSON string which similar to what the [repositories](04-schema.md#repositories)
612  key accepts.
613* **--stability (-s):** Minimum stability of package. Defaults to `stable`.
614* **--prefer-source:** Install packages from `source` when available.
615* **--prefer-dist:** Install packages from `dist` when available.
616* **--dev:** Install packages listed in `require-dev`.
617* **--no-install:** Disables installation of the vendors.
618* **--no-scripts:** Disables the execution of the scripts defined in the root
619  package.
620* **--no-progress:** Removes the progress display that can mess with some
621  terminals or scripts which don't handle backspace characters.
622* **--keep-vcs:** Skip the deletion of the VCS metadata for the created
623  project. This is mostly useful if you run the command in non-interactive
624  mode.
625* **--ignore-platform-reqs:** ignore `php`, `hhvm`, `lib-*` and `ext-*`
626  requirements and force the installation even if the local machine does not
627  fulfill these.
628
629## dump-autoload
630
631If you need to update the autoloader because of new classes in a classmap
632package for example, you can use "dump-autoload" to do that without having to
633go through an install or update.
634
635Additionally, it can dump an optimized autoloader that converts PSR-0/4 packages
636into classmap ones for performance reasons. In large applications with many
637classes, the autoloader can take up a substantial portion of every request's
638time. Using classmaps for everything is less convenient in development, but
639using this option you can still use PSR-0/4 for convenience and classmaps for
640performance.
641
642### Options
643
644* **--optimize (-o):** Convert PSR-0/4 autoloading to classmap to get a faster
645  autoloader. This is recommended especially for production, but can take
646  a bit of time to run so it is currently not done by default.
647* **--classmap-authoritative (-a):** Autoload classes from the classmap only.
648  Implicitly enables `--optimize`.
649* **--no-dev:** Disables autoload-dev rules.
650
651## clear-cache
652
653Deletes all content from Composer's cache directories.
654
655## licenses
656
657Lists the name, version and license of every package installed. Use
658`--format=json` to get machine readable output.
659
660### Options
661
662* **--no-dev:** Remove dev dependencies from the output
663* **--format:** Format of the output: text or json (default: "text")
664
665## run-script
666
667### Options
668
669* **--timeout:** Set the script timeout in seconds, or 0 for no timeout.
670* **--no-dev:** Disable dev mode
671* **--list:** List user defined scripts
672
673To run [scripts](articles/scripts.md) manually you can use this command,
674just give it the script name and optionally any required arguments.
675
676## exec
677
678Executes a vendored binary/script. You can execute any command and this will
679ensure that the Composer bin-dir is pushed on your PATH before the command
680runs.
681
682### Options
683
684* **--list:** List the available composer binaries
685
686## diagnose
687
688If you think you found a bug, or something is behaving strangely, you might
689want to run the `diagnose` command to perform automated checks for many common
690problems.
691
692```sh
693php composer.phar diagnose
694```
695
696## archive
697
698This command is used to generate a zip/tar archive for a given package in a
699given version. It can also be used to archive your entire project without
700excluded/ignored files.
701
702```sh
703php composer.phar archive vendor/package 2.0.21 --format=zip
704```
705
706### Options
707
708* **--format (-f):** Format of the resulting archive: tar or zip (default:
709  "tar")
710* **--dir:** Write the archive to this directory (default: ".")
711
712## help
713
714To get more information about a certain command, just use `help`.
715
716```sh
717php composer.phar help install
718```
719
720## Command-line completion
721
722Command-line completion can be enabled by following instructions
723[on this page](https://github.com/bamarni/symfony-console-autocomplete).
724
725## Environment variables
726
727You can set a number of environment variables that override certain settings.
728Whenever possible it is recommended to specify these settings in the `config`
729section of `composer.json` instead. It is worth noting that the env vars will
730always take precedence over the values specified in `composer.json`.
731
732### COMPOSER
733
734By setting the `COMPOSER` env variable it is possible to set the filename of
735`composer.json` to something else.
736
737For example:
738
739```sh
740COMPOSER=composer-other.json php composer.phar install
741```
742
743The generated lock file will use the same name: `composer-other.lock` in this example.
744
745### COMPOSER_ROOT_VERSION
746
747By setting this var you can specify the version of the root package, if it can
748not be guessed from VCS info and is not present in `composer.json`.
749
750### COMPOSER_VENDOR_DIR
751
752By setting this var you can make Composer install the dependencies into a
753directory other than `vendor`.
754
755### COMPOSER_BIN_DIR
756
757By setting this option you can change the `bin` ([Vendor Binaries](articles/vendor-binaries.md))
758directory to something other than `vendor/bin`.
759
760### http_proxy or HTTP_PROXY
761
762If you are using Composer from behind an HTTP proxy, you can use the standard
763`http_proxy` or `HTTP_PROXY` env vars. Simply set it to the URL of your proxy.
764Many operating systems already set this variable for you.
765
766Using `http_proxy` (lowercased) or even defining both might be preferable since
767some tools like git or curl will only use the lower-cased `http_proxy` version.
768Alternatively you can also define the git proxy using
769`git config --global http.proxy <proxy url>`.
770
771If you are using Composer in a non-CLI context (i.e. integration into a CMS or
772similar use case), and need to support proxies, please provide the `CGI_HTTP_PROXY`
773environment variable instead. See [httpoxy.org](https://httpoxy.org/) for further
774details.
775
776### no_proxy
777
778If you are behind a proxy and would like to disable it for certain domains, you
779can use the `no_proxy` env var. Simply set it to a comma separated list of
780domains the proxy should *not* be used for.
781
782The env var accepts domains, IP addresses, and IP address blocks in CIDR
783notation. You can restrict the filter to a particular port (e.g. `:80`). You
784can also set it to `*` to ignore the proxy for all HTTP requests.
785
786### HTTP_PROXY_REQUEST_FULLURI
787
788If you use a proxy but it does not support the request_fulluri flag, then you
789should set this env var to `false` or `0` to prevent Composer from setting the
790request_fulluri option.
791
792### HTTPS_PROXY_REQUEST_FULLURI
793
794If you use a proxy but it does not support the request_fulluri flag for HTTPS
795requests, then you should set this env var to `false` or `0` to prevent Composer
796from setting the request_fulluri option.
797
798### COMPOSER_HOME
799
800The `COMPOSER_HOME` var allows you to change the Composer home directory. This
801is a hidden, global (per-user on the machine) directory that is shared between
802all projects.
803
804By default it points to `C:\Users\<user>\AppData\Roaming\Composer` on Windows
805and `/Users/<user>/.composer` on OSX. On *nix systems that follow the [XDG Base
806Directory Specifications](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html),
807it points to `$XDG_CONFIG_HOME/composer`. On other *nix systems, it points to
808`/home/<user>/.composer`.
809
810#### COMPOSER_HOME/config.json
811
812You may put a `config.json` file into the location which `COMPOSER_HOME` points
813to. Composer will merge this configuration with your project's `composer.json`
814when you run the `install` and `update` commands.
815
816This file allows you to set [repositories](05-repositories.md) and
817[configuration](06-config.md) for the user's projects.
818
819In case global configuration matches _local_ configuration, the _local_
820configuration in the project's `composer.json` always wins.
821
822### COMPOSER_CACHE_DIR
823
824The `COMPOSER_CACHE_DIR` var allows you to change the Composer cache directory,
825which is also configurable via the [`cache-dir`](06-config.md#cache-dir) option.
826
827By default it points to $COMPOSER_HOME/cache on \*nix and OSX, and
828`C:\Users\<user>\AppData\Local\Composer` (or `%LOCALAPPDATA%/Composer`) on Windows.
829
830### COMPOSER_PROCESS_TIMEOUT
831
832This env var controls the time Composer waits for commands (such as git
833commands) to finish executing. The default value is 300 seconds (5 minutes).
834
835### COMPOSER_CAFILE
836
837By setting this environmental value, you can set a path to a certificate bundle
838file to be used during SSL/TLS peer verification.
839
840### COMPOSER_AUTH
841
842The `COMPOSER_AUTH` var allows you to set up authentication as an environment variable.
843The contents of the variable should be a JSON formatted object containing http-basic,
844github-oauth, bitbucket-oauth, ... objects as needed, and following the
845[spec from the config](06-config.md#gitlab-oauth).
846
847### COMPOSER_DISCARD_CHANGES
848
849This env var controls the [`discard-changes`](06-config.md#discard-changes) config option.
850
851### COMPOSER_NO_INTERACTION
852
853If set to 1, this env var will make Composer behave as if you passed the
854`--no-interaction` flag to every command. This can be set on build boxes/CI.
855
856### COMPOSER_DISABLE_XDEBUG_WARN
857
858If set to 1, this env disables the warning about having xdebug enabled.
859
860### COMPOSER_ALLOW_SUPERUSER
861
862If set to 1, this env disables the warning about running commands as root/super user.
863It also disables automatic clearing of sudo sessions, so you should really only set this
864if you use Composer as super user at all times like in docker containers.
865
866&larr; [Libraries](02-libraries.md)  |  [Schema](04-schema.md) &rarr;
867