From 5896f283be3fdf588ee94f90d0953c5c728679a1 Mon Sep 17 00:00:00 2001 From: "Matthew J. Sahagian" Date: Fri, 21 Nov 2014 13:16:19 -0800 Subject: [PATCH 1/4] Allow for disabling autoloader on Installer --- src/Composer/Installer.php | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index b76155a5a..3654cddd3 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -105,6 +105,7 @@ class Installer protected $dryRun = false; protected $verbose = false; protected $update = false; + protected $runAutoloader = true; protected $runScripts = true; protected $ignorePlatformReqs = false; /** @@ -311,16 +312,18 @@ class Installer } } - // write autoloader - if ($this->optimizeAutoloader) { - $this->io->write('Generating optimized autoload files'); - } else { - $this->io->write('Generating autoload files'); + if ($this->runAutoloader) { + // write autoloader + if ($this->optimizeAutoloader) { + $this->io->write('Generating optimized autoload files'); + } else { + $this->io->write('Generating autoload files'); + } + + $this->autoloadGenerator->setDevMode($this->devMode); + $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader); } - $this->autoloadGenerator->setDevMode($this->devMode); - $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader); - if ($this->runScripts) { // dispatch post event $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD; @@ -1152,6 +1155,21 @@ class Installer return $this; } + + /** + * set whether to run autoloader or not + * + * @param boolean $runAutoloader + * @return Installer + */ + public function setRunAutoloader($runAutoloader = true) + { + $this->runAutoloader = (boolean) $runAutoloader; + + return $this; + } + + /** * set whether to run scripts or not * From 198ac7bc5b52460c8bab140226a6273327565d3b Mon Sep 17 00:00:00 2001 From: "Matthew J. Sahagian" Date: Fri, 21 Nov 2014 13:20:48 -0800 Subject: [PATCH 2/4] Expose no autoloader option to install command --- src/Composer/Command/InstallCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Composer/Command/InstallCommand.php b/src/Composer/Command/InstallCommand.php index 669c03582..c1de25ce7 100644 --- a/src/Composer/Command/InstallCommand.php +++ b/src/Composer/Command/InstallCommand.php @@ -41,6 +41,7 @@ class InstallCommand extends Command new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'), new InputOption('no-plugins', null, InputOption::VALUE_NONE, 'Disables all plugins.'), new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'), + new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'), @@ -113,6 +114,7 @@ EOT ->setPreferSource($preferSource) ->setPreferDist($preferDist) ->setDevMode(!$input->getOption('no-dev')) + ->setRunAutoloader(!$input->getOption('no-autoloader')) ->setRunScripts(!$input->getOption('no-scripts')) ->setOptimizeAutoloader($optimize) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) From 55b2afe9ad5da07277caa1061f06e47f70d24328 Mon Sep 17 00:00:00 2001 From: "Matthew J. Sahagian" Date: Fri, 21 Nov 2014 13:22:17 -0800 Subject: [PATCH 3/4] Expose no autoloader option to update command --- 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 ebfd4cb2a..bebde6ed1 100644 --- a/src/Composer/Command/UpdateCommand.php +++ b/src/Composer/Command/UpdateCommand.php @@ -41,6 +41,7 @@ class UpdateCommand extends Command new InputOption('lock', null, InputOption::VALUE_NONE, 'Only updates the lock file hash to suppress warning about the lock file being out of date.'), new InputOption('no-plugins', null, InputOption::VALUE_NONE, 'Disables all plugins.'), new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'), + new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'), new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'), new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'), new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Add also all dependencies of whitelisted packages to the whitelist.'), @@ -115,6 +116,7 @@ EOT ->setPreferSource($preferSource) ->setPreferDist($preferDist) ->setDevMode(!$input->getOption('no-dev')) + ->setRunAutoloader(!$input->getOption('no-autoloader')) ->setRunScripts(!$input->getOption('no-scripts')) ->setOptimizeAutoloader($optimize) ->setUpdate(true) From 14fe882b4459252ffa09d3944575a21b659c4e42 Mon Sep 17 00:00:00 2001 From: "Matthew J. Sahagian" Date: Fri, 21 Nov 2014 13:28:44 -0800 Subject: [PATCH 4/4] Added no-autoloder option to install and update --- doc/03-cli.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/03-cli.md b/doc/03-cli.md index 7fcafc2d6..0607a45b3 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -88,6 +88,7 @@ resolution. installation and show you what would happen. * **--dev:** Install packages listed in `require-dev` (this is the default behavior). * **--no-dev:** Skip installing packages listed in `require-dev`. +* **--no-autoloader:** Skips autoloader generation. * **--no-scripts:** Skips execution of scripts defined in `composer.json`. * **--no-plugins:** Disables plugins. * **--no-progress:** Removes the progress display that can mess with some @@ -130,6 +131,7 @@ php composer.phar update vendor/* * **--dry-run:** Simulate the command without actually doing anything. * **--dev:** Install packages listed in `require-dev` (this is the default behavior). * **--no-dev:** Skip installing packages listed in `require-dev`. +* **--no-autoloader:** Skips autoloader generation. * **--no-scripts:** Skips execution of scripts defined in `composer.json`. * **--no-plugins:** Disables plugins. * **--no-progress:** Removes the progress display that can mess with some