diff --git a/res/composer-schema.json b/res/composer-schema.json
index 962398447..746e6ca76 100644
--- a/res/composer-schema.json
+++ b/res/composer-schema.json
@@ -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."
},
+ "autoloader-optimize-always": {
+ "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."
diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php
index 89aa072ba..96c8b3ad6 100644
--- a/src/Composer/Command/ConfigCommand.php
+++ b/src/Composer/Command/ConfigCommand.php
@@ -283,6 +283,7 @@ EOT
}
),
'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }),
+ 'autoloader-optimize-always' => array($booleanValidator, $booleanNormalizer),
'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
);
$multiConfigValues = array(
diff --git a/src/Composer/Command/DumpAutoloadCommand.php b/src/Composer/Command/DumpAutoloadCommand.php
index 23ba53167..3902828b0 100644
--- a/src/Composer/Command/DumpAutoloadCommand.php
+++ b/src/Composer/Command/DumpAutoloadCommand.php
@@ -41,12 +41,6 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
- if ($input->getOption('optimize')) {
- $output->writeln('Generating optimized autoload files');
- } else {
- $output->writeln('Generating autoload files');
- }
-
$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('autoloader-optimize-always');
+
+ if ($optimize) {
+ $output->writeln('Generating optimized autoload files');
+ } else {
+ $output->writeln('Generating autoload files');
+ }
+
+ $composer->getAutoloadGenerator()->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
}
}
diff --git a/src/Composer/Config.php b/src/Composer/Config.php
index c54bc498c..9e695094e 100644
--- a/src/Composer/Config.php
+++ b/src/Composer/Config.php
@@ -36,6 +36,7 @@ class Config
'cache-files-maxsize' => '300MiB',
'discard-changes' => false,
'autoloader-suffix' => null,
+ 'autoloader-optimize-always' => false,
'prepend-autoloader' => true,
'github-domains' => array('github.com'),
);