From d3aaeb21dad7597719104432d9ebf1cb8c301229 Mon Sep 17 00:00:00 2001 From: Sebastian Krebs Date: Tue, 23 Oct 2012 13:41:17 +0200 Subject: [PATCH 1/3] Allow autoloader optimization right from 'install' --- src/Composer/Command/InstallCommand.php | 2 ++ src/Composer/Installer.php | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 675f56719..a1777d7bc 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -37,6 +37,7 @@ class InstallCommand extends Command new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), + new InputOption('optimize-autoloaders', null, InputOption::VALUE_NONE, 'Optimize autoloaders during autoloader dump') )) ->setHelp(<<install command reads the composer.lock file from @@ -64,6 +65,7 @@ EOT ->setPreferDist($input->getOption('prefer-dist')) ->setDevMode($input->getOption('dev')) ->setRunScripts(!$input->getOption('no-scripts')) + ->setOptimizeAutoloaders($input->getOption('optimize-autoloaders')) ; if ($input->getOption('no-custom-installers')) { diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 442cbb697..c4e7bf878 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -92,6 +92,7 @@ class Installer protected $preferSource = false; protected $preferDist = false; + protected $optimizeAutoloaders = false; protected $devMode = false; protected $dryRun = false; protected $verbose = false; @@ -221,7 +222,7 @@ class Installer // write autoloader $this->io->write('Generating autoload files'); $localRepos = new CompositeRepository($this->repositoryManager->getLocalRepositories()); - $this->autoloadGenerator->dump($this->config, $localRepos, $this->package, $this->installationManager, 'composer'); + $this->autoloadGenerator->dump($this->config, $localRepos, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloaders); if ($this->runScripts) { // dispatch post event @@ -739,6 +740,19 @@ class Installer return $this; } + /** + * Wether or not generated autoloaders are optimized + * + * @param bool $optimizeAutoloaders + * @return Installer + */ + public function setOptimizeAutoloaders($optimizeAutoloaders = false) + { + $this->optimizeAutoloaders = (boolean) $optimizeAutoloaders; + + return $this; + } + /** * update packages * From 86518a22d7ff332a13fd7ca6b957976f220ef1c5 Mon Sep 17 00:00:00 2001 From: Sebastian Krebs Date: Tue, 23 Oct 2012 13:47:41 +0200 Subject: [PATCH 2/3] Allow autoloader optimization right from 'update' too --- src/Composer/Command/UpdateCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index b92245e4e..fe7ae5533 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -37,6 +37,7 @@ class UpdateCommand extends Command new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), + new InputOption('optimize-autoloaders', null, InputOption::VALUE_NONE, 'Optimize autoloaders during autoloader dump') )) ->setHelp(<<update command reads the composer.json file from the @@ -67,6 +68,7 @@ EOT ->setPreferDist($input->getOption('prefer-dist')) ->setDevMode($input->getOption('dev')) ->setRunScripts(!$input->getOption('no-scripts')) + ->setOptimizeAutoloaders($input->getOption('optimize-autoloaders')) ->setUpdate(true) ->setUpdateWhitelist($input->getArgument('packages')) ; From 578a2163437693ad8764225c70f7c26072c75132 Mon Sep 17 00:00:00 2001 From: Sebastian Krebs Date: Tue, 23 Oct 2012 14:58:41 +0200 Subject: [PATCH 3/3] Add shorthand '-o'-option for '--optimize-autoloaders' --- src/Composer/Command/InstallCommand.php | 2 +- src/Composer/Command/UpdateCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index a1777d7bc..98f240423 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -37,7 +37,7 @@ class InstallCommand extends Command new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), - new InputOption('optimize-autoloaders', null, InputOption::VALUE_NONE, 'Optimize autoloaders during autoloader dump') + new InputOption('optimize-autoloaders', 'o', InputOption::VALUE_NONE, 'Optimize autoloaders during autoloader dump') )) ->setHelp(<<install command reads the composer.lock file from diff --git a/src/Composer/Command/UpdateCommand.php b/src/Composer/Command/UpdateCommand.php index fe7ae5533..de485b47a 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -37,7 +37,7 @@ class UpdateCommand extends Command new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('verbose', 'v', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), - new InputOption('optimize-autoloaders', null, InputOption::VALUE_NONE, 'Optimize autoloaders during autoloader dump') + new InputOption('optimize-autoloaders', 'o', InputOption::VALUE_NONE, 'Optimize autoloaders during autoloader dump') )) ->setHelp(<<update command reads the composer.json file from the