1
0
Fork 0

Merge pull request #2605 from robertboloc/feature-config_optimize_autoload_always

Added config option to optimize the autoloader always
pull/2614/head
Nils Adermann 2014-01-20 10:10:11 -08:00
commit 7adc41d02c
8 changed files with 37 additions and 12 deletions

View File

@ -712,6 +712,8 @@ The following options are supported:
interoperability issues with other autoloaders.
* **autoloader-suffix:** Defaults to `null`. String to be used as a suffix for
the generated Composer autoloader. When null a random one will be generated.
* **optimize-autoloader** Defaults to `false`. Always optimize when dumping
the autoloader.
* **github-domains:** Defaults to `["github.com"]`. A list of domains to use in
github mode. This is used for GitHub Enterprise setups.
* **notify-on-install:** Defaults to `true`. Composer allows repositories to

View File

@ -180,6 +180,10 @@
"type": "string",
"description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
},
"optimize-autoloader": {
"type": "boolean",
"description": "Always optimize when dumping the autoloader"
},
"prepend-autoloader": {
"type": "boolean",
"description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."

View File

@ -283,6 +283,7 @@ EOT
}
),
'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }),
'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
);
$multiConfigValues = array(

View File

@ -41,12 +41,6 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('optimize')) {
$output->writeln('<info>Generating optimized autoload files</info>');
} else {
$output->writeln('<info>Generating autoload files</info>');
}
$composer = $this->getComposer();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
@ -57,6 +51,14 @@ EOT
$package = $composer->getPackage();
$config = $composer->getConfig();
$composer->getAutoloadGenerator()->dump($config, $localRepo, $package, $installationManager, 'composer', $input->getOption('optimize'));
$optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
if ($optimize) {
$output->writeln('<info>Generating optimized autoload files</info>');
} else {
$output->writeln('<info>Generating autoload files</info>');
}
$composer->getAutoloadGenerator()->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
}
}

View File

@ -76,7 +76,10 @@ EOT
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
$config = $composer->getConfig();
switch ($config->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
@ -93,6 +96,8 @@ EOT
$preferDist = $input->getOption('prefer-dist');
}
$optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))
@ -100,7 +105,7 @@ EOT
->setPreferDist($preferDist)
->setDevMode(!$input->getOption('no-dev'))
->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))
->setOptimizeAutoloader($optimize)
;
if ($input->getOption('no-plugins')) {

View File

@ -81,7 +81,10 @@ EOT
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
$config = $composer->getConfig();
switch ($config->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
@ -98,6 +101,8 @@ EOT
$preferDist = $input->getOption('prefer-dist');
}
$optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))
@ -105,7 +110,7 @@ EOT
->setPreferDist($preferDist)
->setDevMode(!$input->getOption('no-dev'))
->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))
->setOptimizeAutoloader($optimize)
->setUpdate(true)
->setUpdateWhitelist($input->getOption('lock') ? array('lock') : $input->getArgument('packages'))
->setWhitelistDependencies($input->getOption('with-dependencies'))

View File

@ -36,6 +36,7 @@ class Config
'cache-files-maxsize' => '300MiB',
'discard-changes' => false,
'autoloader-suffix' => null,
'optimize-autoloader' => false,
'prepend-autoloader' => true,
'github-domains' => array('github.com'),
);

View File

@ -279,7 +279,12 @@ class Installer
}
// write autoloader
$this->io->write('<info>Generating autoload files</info>');
if ($this->optimizeAutoloader) {
$this->io->write('<info>Generating optimized autoload files</info>');
} else {
$this->io->write('<info>Generating autoload files</info>');
}
$this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
if ($this->runScripts) {