protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output)
{
{
$repos = $this->initializeRepos();
$repos = $this->initializeRepos();
$io = $this->getIO();
$return = 0;
$return = 0;
foreach ($input->getArgument('packages') as $packageName) {
foreach ($input->getArgument('packages') as $packageName) {
@ -74,12 +75,12 @@ EOT
if (!$packageExists) {
if (!$packageExists) {
$return = 1;
$return = 1;
$this->getIO()->writeError('<warning>Package '.$packageName.' not found</warning>');
$io->writeError('<warning>Package '.$packageName.' not found</warning>');
}
}
if (!$handled) {
if (!$handled) {
$return = 1;
$return = 1;
$this->getIO()->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
$io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output)
{
{
$io = $this->getIO();
if ($args = $input->getArgument('packages')) {
if ($args = $input->getArgument('packages')) {
$this->getIO()->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
$io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
return 1;
return 1;
}
}
if ($input->getOption('no-custom-installers')) {
if ($input->getOption('no-custom-installers')) {
$this->getIO()->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
$io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
$input->setOption('no-plugins', true);
$input->setOption('no-plugins', true);
}
}
if ($input->getOption('dev')) {
if ($input->getOption('dev')) {
$this->getIO()->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
$io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
$this->getIO()->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
$io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
$this->getIO()->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
$io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
$installedRepo = $platformRepo;
$installedRepo = $platformRepo;
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
$repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
@ -89,9 +89,10 @@ class Application extends BaseApplication
{
{
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
$this->io = new ConsoleIO($input, $output, $this->getHelperSet());
ErrorHandler::register($this->io);
ErrorHandler::register($this->io);
$io = $this->getIO();
if (PHP_VERSION_ID <50302){
if (PHP_VERSION_ID <50302){
$this->getIO()->writeError('<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>');
$io->writeError('<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')) {
if (defined('COMPOSER_DEV_WARNING_TIME')) {
@ -104,7 +105,7 @@ class Application extends BaseApplication
}
}
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
if (time() > COMPOSER_DEV_WARNING_TIME) {
if (time() > COMPOSER_DEV_WARNING_TIME) {
$this->getIO()->writeError(sprintf('<warning>Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
$io->writeError(sprintf('<warning>Warning: This development build of composer is over 60 days old. It is recommended to update it by running "%s self-update" to get the latest version.</warning>', $_SERVER['PHP_SELF']));
}
}
}
}
}
}
@ -117,8 +118,8 @@ class Application extends BaseApplication
if ($newWorkDir = $this->getNewWorkingDir($input)) {
if ($newWorkDir = $this->getNewWorkingDir($input)) {
$oldWorkingDir = getcwd();
$oldWorkingDir = getcwd();
chdir($newWorkDir);
chdir($newWorkDir);
if ($this->getIO()->isDebug() >= 4) {
if ($io->isDebug() >= 4) {
$this->getIO()->writeError('Changed CWD to ' . getcwd());
$io->writeError('Changed CWD to ' . getcwd());
}
}
}
}
@ -129,7 +130,7 @@ class Application extends BaseApplication
foreach ($composer['scripts'] as $script => $dummy) {
foreach ($composer['scripts'] as $script => $dummy) {
if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
if ($this->has($script)) {
if ($this->has($script)) {
$this->getIO()->writeError('<warning>A script named '.$script.' would override a native Composer function and has been skipped</warning>');
$io->writeError('<warning>A script named '.$script.' would override a native Composer function and has been skipped</warning>');
$this->getIO()->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>');
$io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>');
}
}
}
}
} catch (\Exception $e) {
} catch (\Exception $e) {
}
}
if (defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
if (defined('PHP_WINDOWS_VERSION_BUILD') && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
$this->getIO()->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
$io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>');
$this->getIO()->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>');
$io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#-the-system-cannot-find-the-path-specified-windows- for details</error>');