12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- /*
- * This file is part of Composer.
- *
- * (c) Nils Adermann <naderman@naderman.de>
- * Jordi Boggiano <j.boggiano@seld.be>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Composer\Command;
- use Composer\Installer;
- use Composer\Script\EventDispatcher;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\OutputInterface;
- /**
- * @author Jordi Boggiano <j.boggiano@seld.be>
- */
- class UpdateCommand extends Command
- {
- protected function configure()
- {
- $this
- ->setName('update')
- ->setDescription('Updates your dependencies to the latest version, and updates the composer.lock file.')
- ->setDefinition(array(
- new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
- new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
- new InputOption('install-recommends', null, InputOption::VALUE_NONE, 'Also install recommended packages.'),
- new InputOption('install-suggests', null, InputOption::VALUE_NONE, 'Also install suggested packages.'),
- ))
- ->setHelp(<<<EOT
- The <info>update</info> command reads the composer.json file from the
- current directory, processes it, and updates, removes or installs all the
- dependencies.
- <info>php composer.phar update</info>
- EOT
- )
- ;
- }
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $composer = $this->getComposer();
- $io = $this->getApplication()->getIO();
- $eventDispatcher = new EventDispatcher($composer, $io);
- $install = Installer::create($io, $composer, $eventDispatcher);
- $install
- ->setDryRun($input->getOption('dry-run'))
- ->setVerbose($input->getOption('verbose'))
- ->setPreferSource($input->getOption('prefer-source'))
- ->setInstallRecommends($input->getOption('install-recommends'))
- ->setInstallSuggests($input->getOption('install-suggests'))
- ->setUpdate(true)
- ;
- return $install->run();
- }
- }
|