Example #1
0
 /**
  * {@inheritDoc}
  */
 public function execute(Project $project)
 {
     $this->debug(sprintf('Using stub file <comment>%s</comment> (%s)', $this->name, MiscUtils::formatFileSize(filesize($this->name))));
     $project->getPhar()->setStubFromFileFiltered($this->name);
 }
 /**
  * {@inheritDoc}
  */
 public function execute(Project $project)
 {
     $composer = $project->getComposer();
     $packages = $this->filteredPackages($composer);
     $prefixLength = strlen($composer->getPackageDirectory($composer->getRootPackageName()));
     $phar = $project->getPhar();
     foreach ($packages as $package) {
         $this->info('Adding package <comment>' . $package . '</comment>');
         $packageRoot = $composer->getPackageDirectory($package);
         $packageRelative = substr($packageRoot, $prefixLength);
         foreach ($this->prepareFinder($packageRoot, $package) as $file) {
             /** @var SplFileInfo $file */
             $filePath = $file->getPathname();
             $localPath = $this->rewritePath($file->getRelativePathname(), $package, $packageRelative);
             $this->debug(sprintf('Adding file <comment>%s</comment> (%s)', $localPath, MiscUtils::formatFileSize(filesize($filePath))));
             $phar->addFileFiltered($filePath, $localPath);
         }
     }
 }
 /**
  * Optimize the autoloader and add it then.
  *
  * @param Project $project The project.
  *
  * @return void
  */
 private function addOptimized(Project $project)
 {
     $this->info('Optimizing autoloader...');
     $root = $project->getComposer()->getPackageDirectory($project->getComposer()->getRootPackageName());
     $this->debug(sprintf('Adding file <comment>/vendor/composer/ClassLoader.php</comment> (%s)', MiscUtils::formatFileSize(filesize($root . '/vendor/composer/ClassLoader.php'))));
     $phar = $project->getPhar();
     $phar->addFileFiltered($root . '/vendor/composer/ClassLoader.php', '/vendor/composer/ClassLoader.php');
     $optimizer = AutoloadInformationOptimizer::create($phar->getFileList(), $root);
     $dumper = new AutoloadDumper($optimizer);
     $phar->addFromString('/vendor/composer/autoload_real.php', $dumper->getAutoloadReal());
     $phar->addFromString('/vendor/autoload.php', $dumper->getAutoload());
 }