Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. InstallCommand.php

function InstallCommand::execute

Same name in this branch
  1. 11.1.x core/lib/Drupal/Core/Command/InstallCommand.php \Drupal\Core\Command\InstallCommand::execute()

Overrides Command::execute

File

vendor/composer/composer/src/Composer/Command/InstallCommand.php, line 82

Class

InstallCommand
@author Jordi Boggiano <j.boggiano@seld.be> @author Ryan Weaver <ryan@knplabs.com> @author Konstantin Kudryashov <ever.zet@gmail.com> @author Nils Adermann <naderman@naderman.de>

Namespace

Composer\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) : int {
    $io = $this->getIO();
    if ($input->getOption('dev')) {
        $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
    }
    if ($input->getOption('no-suggest')) {
        $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
    }
    $args = $input->getArgument('packages');
    if (count($args) > 0) {
        $io->writeError('<error>Invalid argument ' . implode(' ', $args) . '. Use "composer require ' . implode(' ', $args) . '" instead to add packages to your composer.json.</error>');
        return 1;
    }
    if ($input->getOption('no-install')) {
        $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
        return 1;
    }
    $composer = $this->requireComposer();
    if (!$composer->getLocker()
        ->isLocked() && !HttpDownloader::isCurlEnabled()) {
        $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
    }
    $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
    $composer->getEventDispatcher()
        ->dispatch($commandEvent->getName(), $commandEvent);
    $install = Installer::create($io, $composer);
    $config = $composer->getConfig();
    [
        $preferSource,
        $preferDist,
    ] = $this->getPreferredInstallOptions($config, $input);
    $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
    $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
    $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
    $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
    $composer->getInstallationManager()
        ->setOutputProgress(!$input->getOption('no-progress'));
    $install->setDryRun($input->getOption('dry-run'))
        ->setDownloadOnly($input->getOption('download-only'))
        ->setVerbose($input->getOption('verbose'))
        ->setPreferSource($preferSource)
        ->setPreferDist($preferDist)
        ->setDevMode(!$input->getOption('no-dev'))
        ->setDumpAutoloader(!$input->getOption('no-autoloader'))
        ->setOptimizeAutoloader($optimize)
        ->setClassMapAuthoritative($authoritative)
        ->setApcuAutoloader($apcu, $apcuPrefix)
        ->setPlatformRequirementFilter($this->getPlatformRequirementFilter($input))
        ->setAudit($input->getOption('audit'))
        ->setErrorOnAudit($input->getOption('audit'))
        ->setAuditFormat($this->getAuditFormat($input));
    if ($input->getOption('no-plugins')) {
        $install->disablePlugins();
    }
    return $install->run();
}
RSS feed
Powered by Drupal