Browse Source

Allow for disabling autoloader on Installer

Matthew J. Sahagian 10 years ago
parent
commit
5896f283be
1 changed files with 26 additions and 8 deletions
  1. 26 8
      src/Composer/Installer.php

+ 26 - 8
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('<info>Generating optimized autoload files</info>');
-            } else {
-                $this->io->write('<info>Generating autoload files</info>');
+            if ($this->runAutoloader) {
+                // write autoloader
+                if ($this->optimizeAutoloader) {
+                    $this->io->write('<info>Generating optimized autoload files</info>');
+                } else {
+                    $this->io->write('<info>Generating autoload files</info>');
+                }
+    
+                $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
      *