1
0
Fork 0

Update docs, config command and schema with all the config values

pull/1579/head
Jordi Boggiano 2013-02-12 11:16:52 +01:00
parent 5165008be7
commit 94e99b9c8b
4 changed files with 96 additions and 29 deletions

View File

@ -584,13 +584,11 @@ A set of configuration options. It is only used for projects.
The following options are supported:
* **vendor-dir:** Defaults to `vendor`. You can install dependencies into a
different directory if you want to.
* **bin-dir:** Defaults to `vendor/bin`. If a project includes binaries, they
will be symlinked into this directory.
* **process-timeout:** Defaults to `300`. The duration processes like git clones
can run before Composer assumes they died out. You may need to make this
higher if you have a slow connection or huge vendors.
* **use-include-path:** Defaults to `false`. If true, the Composer autoloader
will also look for classes in the PHP include path.
* **github-protocols:** Defaults to `["git", "https", "http"]`. A list of
protocols to use for github.com clones, in priority order. Use this if you are
behind a proxy or have somehow bad performances with the git protocol.
@ -598,6 +596,10 @@ The following options are supported:
`{"github.com": "oauthtoken"}` as the value of this option will use `oauthtoken`
to access private repositories on github and to circumvent the low IP-based
rate limiting of their API.
* **vendor-dir:** Defaults to `vendor`. You can install dependencies into a
different directory if you want to.
* **bin-dir:** Defaults to `vendor/bin`. If a project includes binaries, they
will be symlinked into this directory.
* **cache-dir:** Defaults to `$home/cache` on unix systems and
`C:\Users\<user>\AppData\Local\Composer` on Windows. Stores all the caches
used by composer. See also [COMPOSER_HOME](03-cli.md#composer-home).
@ -611,6 +613,10 @@ The following options are supported:
dist (zip, tar, ..) packages that it downloads. Those are purged after six
months of being unused by default. This option allows you to tweak this
duration (in seconds) or disable it completely by setting it to 0.
* **cache-files-maxsize:** Defaults to `300MiB`. Composer caches all
dist (zip, tar, ..) packages that it downloads. When the garbage collection
is periodically ran, this is the maximum size the cache will be able to use.
Older (less used) files will be removed first until the cache fits.
* **notify-on-install:** Defaults to `true`. Composer allows repositories to
define a notification URL, so that they get notified whenever a package from
that repository is installed. This option allows you to disable that behaviour.

View File

@ -105,21 +105,17 @@
"additionalProperties": true
},
"config": {
"type": ["object"],
"type": "object",
"description": "Composer options.",
"properties": {
"vendor-dir": {
"type": "string",
"description": "The location where all packages are installed, defaults to \"vendor\"."
},
"bin-dir": {
"type": "string",
"description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
},
"process-timeout": {
"type": "integer",
"description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
},
"use-include-path": {
"type": "boolean",
"description": "If true, the Composer autoloader will also look for classes in the PHP include path."
},
"notify-on-install": {
"type": "boolean",
"description": "Composer allows repositories to define a notification URL, so that they get notified whenever a package from that repository is installed. This option allows you to disable that behaviour, defaults to true."
@ -130,6 +126,47 @@
"items": {
"type": "string"
}
},
"github-oauth": {
"type": "object",
"description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
"additionalProperties": true
},
"vendor-dir": {
"type": "string",
"description": "The location where all packages are installed, defaults to \"vendor\"."
},
"bin-dir": {
"type": "string",
"description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
},
"cache-dir": {
"type": "string",
"description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
},
"cache-files-dir": {
"type": "string",
"description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
},
"cache-repo-dir": {
"type": "string",
"description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
},
"cache-vcs-dir": {
"type": "string",
"description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
},
"cache-ttl": {
"type": "integer",
"description": "The default cache time-to-live, defaults to 15552000 (6 months)."
},
"cache-files-ttl": {
"type": "integer",
"description": "The cache time-to-live for files, defaults to the value of cache-ttl."
},
"cache-files-maxsize": {
"type": ["string", "integer"],
"description": "The cache max size for the files cache, defaults to \"300MiB\"."
}
}
},

View File

@ -157,7 +157,7 @@ EOT
// List the configuration of the file settings
if ($input->getOption('list')) {
$this->listConfiguration($this->config->all(), $output);
$this->listConfiguration($this->config->all(), $this->config->raw(), $output);
return 0;
}
@ -251,17 +251,25 @@ EOT
// handle config values
$uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'),
'cache-ttl' => array('is_numeric', 'intval'),
'cache-files-ttl' => array('is_numeric', 'intval'),
'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }),
'use-include-path' => array(
function ($val) { return true; },
function ($val) { return $val !== 'false' && (bool) $val; }
),
'notify-on-install' => array(
function ($val) { return true; },
function ($val) { return $val !== 'false' && (bool) $val; }
),
'use-include-path' => array(
function ($val) { return false; },
function ($val) { return $val !== 'false' && (bool) $val; }
'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }),
'cache-dir' => array('is_string', function ($val) { return $val; }),
'cache-files-dir' => array('is_string', function ($val) { return $val; }),
'cache-repo-dir' => array('is_string', function ($val) { return $val; }),
'cache-vcs-dir' => array('is_string', function ($val) { return $val; }),
'cache-ttl' => array('is_numeric', 'intval'),
'cache-files-ttl' => array('is_numeric', 'intval'),
'cache-files-maxsize' => array(
function ($val) { return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0; },
function ($val) { return $val; }
),
);
$multiConfigValues = array(
@ -332,10 +340,11 @@ EOT
* Display the contents of the file in a pretty formatted way
*
* @param array $contents
* @param array $rawContents
* @param OutputInterface $output
* @param string|null $k
*/
protected function listConfiguration(array $contents, OutputInterface $output, $k = null)
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
{
$origK = $k;
foreach ($contents as $key => $value) {
@ -343,9 +352,11 @@ EOT
continue;
}
$rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
$k .= preg_replace('{^config\.}', '', $key . '.');
$this->listConfiguration($value, $output, $k);
$this->listConfiguration($value, $rawVal, $output, $k);
if (substr_count($k, '.') > 1) {
$k = str_split($k, strrpos($k, '.', -2));
@ -369,7 +380,11 @@ EOT
$value = var_export($value, true);
}
if (is_string($rawVal) && $rawVal != $value) {
$output->writeln('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>');
} else {
$output->writeln('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>');
}
}
}
}

View File

@ -21,17 +21,18 @@ class Config
{
public static $defaultConfig = array(
'process-timeout' => 300,
'cache-ttl' => 15552000, // 6 months
'cache-files-maxsize' => '300MiB',
'vendor-dir' => 'vendor',
'bin-dir' => '{$vendor-dir}/bin',
'use-include-path' => false,
'notify-on-install' => true,
'github-protocols' => array('git', 'https', 'http'),
'vendor-dir' => 'vendor',
'bin-dir' => '{$vendor-dir}/bin',
'cache-dir' => '{$home}/cache',
'cache-files-dir' => '{$cache-dir}/files',
'cache-repo-dir' => '{$cache-dir}/repo',
'cache-vcs-dir' => '{$cache-dir}/vcs',
'use-include-path' => false,
'cache-ttl' => 15552000, // 6 months
'cache-files-ttl' => null, // fallback to cache-ttl
'cache-files-maxsize' => '300MiB',
);
public static $defaultRepositories = array(
@ -193,6 +194,14 @@ class Config
return $all;
}
public function raw()
{
return array(
'repositories' => $this->getRepositories(),
'config' => $this->config,
);
}
/**
* Checks whether a setting exists
*