PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/doc/06-config.md

https://github.com/naderman/composer
Markdown | 338 lines | 239 code | 99 blank | 0 comment | 0 complexity | 549954ef147124d6adcd059cb47fb887 MD5 | raw file
  1. # Config
  2. This chapter will describe the `config` section of the `composer.json`
  3. [schema](04-schema.md).
  4. ## process-timeout
  5. The timeout in seconds for process executions, defaults to 300 (5mins).
  6. The duration processes like git clones can run before
  7. Composer assumes they died out. You may need to make this higher if you have a
  8. slow connection or huge vendors.
  9. To disable the process timeout on a custom command under `scripts`, a static
  10. helper is available:
  11. ```json
  12. {
  13. "scripts": {
  14. "test": [
  15. "Composer\\Config::disableProcessTimeout",
  16. "phpunit"
  17. ]
  18. }
  19. }
  20. ```
  21. ## use-include-path
  22. Defaults to `false`. If `true`, the Composer autoloader will also look for classes
  23. in the PHP include path.
  24. ## preferred-install
  25. Defaults to `auto` and can be any of `source`, `dist` or `auto`. This option
  26. allows you to set the install method Composer will prefer to use. Can
  27. optionally be a hash of patterns for more granular install preferences.
  28. ```json
  29. {
  30. "config": {
  31. "preferred-install": {
  32. "my-organization/stable-package": "dist",
  33. "my-organization/*": "source",
  34. "partner-organization/*": "auto",
  35. "*": "dist"
  36. }
  37. }
  38. }
  39. ```
  40. > **Note:** Order matters. More specific patterns should be earlier than
  41. > more relaxed patterns. When mixing the string notation with the hash
  42. > configuration in global and package configurations the string notation
  43. > is translated to a `*` package pattern.
  44. ## store-auths
  45. What to do after prompting for authentication, one of: `true` (always store),
  46. `false` (do not store) and `"prompt"` (ask every time), defaults to `"prompt"`.
  47. ## github-protocols
  48. Defaults to `["https", "ssh", "git"]`. A list of protocols to use when cloning
  49. from github.com, in priority order. By default `git` is present but only if [secure-http](#secure-http)
  50. is disabled, as the git protocol is not encrypted. If you want your origin remote
  51. push URLs to be using https and not ssh (`git@github.com:...`), then set the protocol
  52. list to be only `["https"]` and Composer will stop overwriting the push URL to an ssh
  53. URL.
  54. ## github-oauth
  55. A list of domain names and oauth keys. For example using `{"github.com":
  56. "oauthtoken"}` as the value of this option will use `oauthtoken` to access
  57. private repositories on github and to circumvent the low IP-based rate limiting
  58. of their API. Composer may prompt for credentials when needed, but these can also be
  59. manually set. Read more on how to get an OAuth token for GitHub and cli syntax
  60. [here](articles/authentication-for-private-packages.md#github-oauth).
  61. ## gitlab-oauth
  62. A list of domain names and oauth keys. For example using `{"gitlab.com":
  63. "oauthtoken"}` as the value of this option will use `oauthtoken` to access
  64. private repositories on gitlab. Please note: If the package is not hosted at
  65. gitlab.com the domain names must be also specified with the
  66. [`gitlab-domains`](06-config.md#gitlab-domains) option.
  67. Further info can also be found [here](articles/authentication-for-private-packages.md#gitlab-oauth)
  68. ## gitlab-token
  69. A list of domain names and private tokens. Private token can be either simple
  70. string, or array with username and token. For example using `{"gitlab.com":
  71. "privatetoken"}` as the value of this option will use `privatetoken` to access
  72. private repositories on gitlab. Using `{"gitlab.com": {"username": "gitlabuser",
  73. "token": "privatetoken"}}` will use both username and token for gitlab deploy
  74. token functionality (https://docs.gitlab.com/ee/user/project/deploy_tokens/)
  75. Please note: If the package is not hosted at
  76. gitlab.com the domain names must be also specified with the
  77. [`gitlab-domains`](06-config.md#gitlab-domains) option. The token must have
  78. `api` or `read_api` scope.
  79. Further info can also be found [here](articles/authentication-for-private-packages.md#gitlab-token)
  80. ## disable-tls
  81. Defaults to `false`. If set to true all HTTPS URLs will be tried with HTTP
  82. instead and no network level encryption is performed. Enabling this is a
  83. security risk and is NOT recommended. The better way is to enable the
  84. php_openssl extension in php.ini. Enabling this will implicitly disable the
  85. `secure-http` option.
  86. ## secure-http
  87. Defaults to `true`. If set to true only HTTPS URLs are allowed to be
  88. downloaded via Composer. If you really absolutely need HTTP access to something
  89. then you can disable it, but using [Let's Encrypt](https://letsencrypt.org/) to
  90. get a free SSL certificate is generally a better alternative.
  91. ## bitbucket-oauth
  92. A list of domain names and consumers. For example using `{"bitbucket.org":
  93. {"consumer-key": "myKey", "consumer-secret": "mySecret"}}`.
  94. Read more [here](articles/authentication-for-private-packages.md#bitbucket-oauth).
  95. ## cafile
  96. Location of Certificate Authority file on local filesystem. In PHP 5.6+ you
  97. should rather set this via openssl.cafile in php.ini, although PHP 5.6+ should
  98. be able to detect your system CA file automatically.
  99. ## capath
  100. If cafile is not specified or if the certificate is not found there, the
  101. directory pointed to by capath is searched for a suitable certificate.
  102. capath must be a correctly hashed certificate directory.
  103. ## http-basic
  104. A list of domain names and username/passwords to authenticate against them. For
  105. example using `{"example.org": {"username": "alice", "password": "foo"}}` as the
  106. value of this option will let Composer authenticate against example.org.
  107. More info can be found [here](articles/authentication-for-private-packages.md#http-basic).
  108. ## bearer
  109. A list of domain names and tokens to authenticate against them. For example using
  110. `{"example.org": "foo"}` as the value of this option will let Composer authenticate
  111. against example.org using an `Authorization: Bearer foo` header.
  112. ## platform
  113. Lets you fake platform packages (PHP and extensions) so that you can emulate a
  114. production env or define your target platform in the config. Example: `{"php":
  115. "7.0.3", "ext-something": "4.0.3"}`.
  116. This will make sure that no package requiring more than PHP 7.0.3 can be installed
  117. regardless of the actual PHP version you run locally. However it also means
  118. the dependencies are not checked correctly anymore, if you run PHP 5.6 it will
  119. install fine as it assumes 7.0.3, but then it will fail at runtime.
  120. Therefore if you use this it is recommended, and safer, to also run the
  121. [`check-platform-reqs`](03-cli.md#check-platform-reqs) command as part of your
  122. deployment strategy.
  123. If a dependency requires some extension that you do not have installed locally
  124. you may ignore it instead by passing `--ignore-platform-req=ext-foo` to `update`,
  125. `install` or `require`. In the long run though you should install required
  126. extensions as if you ignore one now and a new package you add a month later also
  127. requires it, you may introduce issues in production unknowingly.
  128. ## vendor-dir
  129. Defaults to `vendor`. You can install dependencies into a different directory if
  130. you want to. `$HOME` and `~` will be replaced by your home directory's path in
  131. vendor-dir and all `*-dir` options below.
  132. ## bin-dir
  133. Defaults to `vendor/bin`. If a project includes binaries, they will be symlinked
  134. into this directory.
  135. ## data-dir
  136. Defaults to `C:\Users\<user>\AppData\Roaming\Composer` on Windows,
  137. `$XDG_DATA_HOME/composer` on unix systems that follow the XDG Base Directory
  138. Specifications, and `$home` on other unix systems. Right now it is only
  139. used for storing past composer.phar files to be able to rollback to older
  140. versions. See also [COMPOSER_HOME](03-cli.md#composer-home).
  141. ## cache-dir
  142. Defaults to `C:\Users\<user>\AppData\Local\Composer` on Windows,
  143. `$XDG_CACHE_HOME/composer` on unix systems that follow the XDG Base Directory
  144. Specifications, and `$home/cache` on other unix systems. Stores all the caches
  145. used by Composer. See also [COMPOSER_HOME](03-cli.md#composer-home).
  146. ## cache-files-dir
  147. Defaults to `$cache-dir/files`. Stores the zip archives of packages.
  148. ## cache-repo-dir
  149. Defaults to `$cache-dir/repo`. Stores repository metadata for the `composer`
  150. type and the VCS repos of type `svn`, `fossil`, `github` and `bitbucket`.
  151. ## cache-vcs-dir
  152. Defaults to `$cache-dir/vcs`. Stores VCS clones for loading VCS repository
  153. metadata for the `git`/`hg` types and to speed up installs.
  154. ## cache-files-ttl
  155. Defaults to `15552000` (6 months). Composer caches all dist (zip, tar, ...)
  156. packages that it downloads. Those are purged after six months of being unused by
  157. default. This option allows you to tweak this duration (in seconds) or disable
  158. it completely by setting it to 0.
  159. ## cache-files-maxsize
  160. Defaults to `300MiB`. Composer caches all dist (zip, tar, ...) packages that it
  161. downloads. When the garbage collection is periodically ran, this is the maximum
  162. size the cache will be able to use. Older (less used) files will be removed
  163. first until the cache fits.
  164. ## cache-read-only
  165. Defaults to `false`. Whether to use the Composer cache in read-only mode.
  166. ## bin-compat
  167. Defaults to `auto`. Determines the compatibility of the binaries to be installed.
  168. If it is `auto` then Composer only installs .bat proxy files when on Windows. If
  169. set to `full` then both .bat files for Windows and scripts for Unix-based
  170. operating systems will be installed for each binary. This is mainly useful if you
  171. run Composer inside a linux VM but still want the .bat proxies available for use
  172. in the Windows host OS.
  173. ## prepend-autoloader
  174. Defaults to `true`. If `false`, the Composer autoloader will not be prepended to
  175. existing autoloaders. This is sometimes required to fix interoperability issues
  176. with other autoloaders.
  177. ## autoloader-suffix
  178. Defaults to `null`. String to be used as a suffix for the generated Composer
  179. autoloader. When null a random one will be generated.
  180. ## optimize-autoloader
  181. Defaults to `false`. If `true`, always optimize when dumping the autoloader.
  182. ## sort-packages
  183. Defaults to `false`. If `true`, the `require` command keeps packages sorted
  184. by name in `composer.json` when adding a new package.
  185. ## classmap-authoritative
  186. Defaults to `false`. If `true`, the Composer autoloader will only load classes
  187. from the classmap. Implies `optimize-autoloader`.
  188. ## apcu-autoloader
  189. Defaults to `false`. If `true`, the Composer autoloader will check for APCu and
  190. use it to cache found/not-found classes when the extension is enabled.
  191. ## github-domains
  192. Defaults to `["github.com"]`. A list of domains to use in github mode. This is
  193. used for GitHub Enterprise setups.
  194. ## github-expose-hostname
  195. Defaults to `true`. If `false`, the OAuth tokens created to access the
  196. github API will have a date instead of the machine hostname.
  197. ## gitlab-domains
  198. Defaults to `["gitlab.com"]`. A list of domains of GitLab servers.
  199. This is used if you use the `gitlab` repository type.
  200. ## use-github-api
  201. Defaults to `true`. Similar to the `no-api` key on a specific repository,
  202. setting `use-github-api` to `false` will define the global behavior for all
  203. GitHub repositories to clone the repository as it would with any other git
  204. repository instead of using the GitHub API. But unlike using the `git`
  205. driver directly, Composer will still attempt to use GitHub's zip files.
  206. ## notify-on-install
  207. Defaults to `true`. Composer allows repositories to define a notification URL,
  208. so that they get notified whenever a package from that repository is installed.
  209. This option allows you to disable that behavior.
  210. ## discard-changes
  211. Defaults to `false` and can be any of `true`, `false` or `"stash"`. This option
  212. allows you to set the default style of handling dirty updates when in
  213. non-interactive mode. `true` will always discard changes in vendors, while
  214. `"stash"` will try to stash and reapply. Use this for CI servers or deploy
  215. scripts if you tend to have modified vendors.
  216. ## archive-format
  217. Defaults to `tar`. Overrides the default format used by the archive command.
  218. ## archive-dir
  219. Defaults to `.`. Default destination for archives created by the archive
  220. command.
  221. Example:
  222. ```json
  223. {
  224. "config": {
  225. "archive-dir": "/home/user/.composer/repo"
  226. }
  227. }
  228. ```
  229. ## htaccess-protect
  230. Defaults to `true`. If set to `false`, Composer will not create `.htaccess` files
  231. in the composer home, cache, and data directories.
  232. ## lock
  233. Defaults to `true`. If set to `false`, Composer will not create a `composer.lock`
  234. file.
  235. ## platform-check
  236. Defaults to `php-only` which only checks the PHP version. Set to `true` to also
  237. check the presence of extension. If set to `false`, Composer will not create and
  238. require a `platform_check.php` file as part of the autoloader bootstrap.
  239. &larr; [Repositories](05-repositories.md) | [Runtime](07-runtime.md) &rarr;