DumpAutoloadCommand.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Command;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Input\InputOption;
  14. use Composer\Repository\CompositeRepository;
  15. use Symfony\Component\Console\Output\OutputInterface;
  16. use Composer\Autoload\AutoloadGenerator;
  17. /**
  18. * @author Jordi Boggiano <j.boggiano@seld.be>
  19. */
  20. class DumpAutoloadCommand extends Command
  21. {
  22. protected function configure()
  23. {
  24. $this
  25. ->setName('dump-autoload')
  26. ->setAliases(array('dumpautoload'))
  27. ->setDescription('Dumps the autoloader')
  28. ->setDefinition(array(
  29. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 packages to be loaded with classmaps too, good for production.'),
  30. ))
  31. ->setHelp(<<<EOT
  32. <info>php composer.phar dump-autoload</info>
  33. EOT
  34. )
  35. ;
  36. }
  37. protected function execute(InputInterface $input, OutputInterface $output)
  38. {
  39. $output->writeln('<info>Generating autoload files</info>');
  40. $composer = $this->getComposer();
  41. $installationManager = $composer->getInstallationManager();
  42. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  43. $package = $composer->getPackage();
  44. $config = $composer->getConfig();
  45. $composer->getAutoloadGenerator()->dump($config, $localRepo, $package, $installationManager, 'composer', $input->getOption('optimize'));
  46. }
  47. }