InstallCommand.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 Composer\Install;
  13. use Composer\Script\EventDispatcher;
  14. use Symfony\Component\Console\Input\InputInterface;
  15. use Symfony\Component\Console\Input\InputOption;
  16. use Symfony\Component\Console\Output\OutputInterface;
  17. /**
  18. * @author Jordi Boggiano <j.boggiano@seld.be>
  19. * @author Ryan Weaver <ryan@knplabs.com>
  20. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  21. */
  22. class InstallCommand extends Command
  23. {
  24. protected function configure()
  25. {
  26. $this
  27. ->setName('install')
  28. ->setDescription('Parses the composer.json file and downloads the needed dependencies.')
  29. ->setDefinition(array(
  30. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  31. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  32. new InputOption('no-install-recommends', null, InputOption::VALUE_NONE, 'Do not install recommended packages (ignored when installing from an existing lock file).'),
  33. new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages (ignored when installing from an existing lock file).'),
  34. ))
  35. ->setHelp(<<<EOT
  36. The <info>install</info> command reads the composer.json file from the
  37. current directory, processes it, and downloads and installs all the
  38. libraries and dependencies outlined in that file.
  39. <info>php composer.phar install</info>
  40. EOT
  41. )
  42. ;
  43. }
  44. protected function execute(InputInterface $input, OutputInterface $output)
  45. {
  46. $composer = $this->getComposer();
  47. $io = $this->getApplication()->getIO();
  48. $eventDispatcher = new EventDispatcher($composer, $io);
  49. $install = new Install;
  50. return $install->run(
  51. $io,
  52. $composer,
  53. $eventDispatcher,
  54. (Boolean)$input->getOption('prefer-source'),
  55. (Boolean)$input->getOption('dry-run'),
  56. (Boolean)$input->getOption('verbose'),
  57. (Boolean)$input->getOption('no-install-recommends'),
  58. (Boolean)$input->getOption('install-suggests')
  59. );
  60. }
  61. }