Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 159 lines (136 sloc) 4.655 kb
<?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\Console;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Composer\Command;
use Composer\Command\Helper\DialogHelper;
use Composer\Composer;
use Composer\Factory;
use Composer\IO\IOInterface;
use Composer\IO\ConsoleIO;
use Composer\Util\ErrorHandler;
/**
* The console application that handles the commands
*
* @author Ryan Weaver <ryan@knplabs.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author François Pluchino <francois.pluchino@opendisplay.com>
*/
class Application extends BaseApplication
{
/**
* @var Composer
*/
protected $composer;
/**
* @var IOInterface
*/
protected $io;
public function __construct()
{
ErrorHandler::register();
parent::__construct('Composer', Composer::VERSION);
}
/**
* {@inheritDoc}
*/
public function run(InputInterface $input = null, OutputInterface $output = null)
{
if (null === $output) {
$styles['highlight'] = new OutputFormatterStyle('red');
$styles['warning'] = new OutputFormatterStyle('black', 'yellow');
$formatter = new OutputFormatter(null, $styles);
$output = new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
}
return parent::run($input, $output);
}
/**
* {@inheritDoc}
*/
public function doRun(InputInterface $input, OutputInterface $output)
{
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
if (version_compare(PHP_VERSION, '5.3.2', '<')) {
$output->writeln('<warning>Composer only officially supports PHP 5.3.2 and above, you will most likely encounter problems with your PHP '.PHP_VERSION.', upgrading is strongly recommended.</warning>');
}
if (defined('COMPOSER_DEV_WARNING_TIME') && $this->getCommandName($input) !== 'self-update') {
if (time() > COMPOSER_DEV_WARNING_TIME) {
$output->writeln(sprintf('<warning>This dev build of composer is outdated, please run "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
}
}
return parent::doRun($input, $output);
}
/**
* @param bool $required
* @return Composer
*/
public function getComposer($required = true)
{
if (null === $this->composer) {
try {
$this->composer = Factory::create($this->io);
} catch (\InvalidArgumentException $e) {
if ($required) {
$this->io->write($e->getMessage());
exit(1);
}
}
}
return $this->composer;
}
/**
* @return IOInterface
*/
public function getIO()
{
return $this->io;
}
/**
* Initializes all the composer commands
*/
protected function getDefaultCommands()
{
$commands = parent::getDefaultCommands();
$commands[] = new Command\AboutCommand();
$commands[] = new Command\DependsCommand();
$commands[] = new Command\InitCommand();
$commands[] = new Command\InstallCommand();
$commands[] = new Command\CreateProjectCommand();
$commands[] = new Command\UpdateCommand();
$commands[] = new Command\SearchCommand();
$commands[] = new Command\ValidateCommand();
$commands[] = new Command\ShowCommand();
$commands[] = new Command\RequireCommand();
$commands[] = new Command\DumpAutoloadCommand();
$commands[] = new Command\StatusCommand();
if ('phar:' === substr(__FILE__, 0, 5)) {
$commands[] = new Command\SelfUpdateCommand();
}
if (function_exists('symlink')) {
$commands[] = new Command\LinkCommand();
}
return $commands;
}
/**
* {@inheritDoc}
*/
protected function getDefaultHelperSet()
{
$helperSet = parent::getDefaultHelperSet();
$helperSet->set(new DialogHelper());
return $helperSet;
}
}
Jump to Line
Something went wrong with that request. Please try again.