class InstallCommand
Same name in this branch
- 11.1.x core/lib/Drupal/Core/Command/InstallCommand.php \Drupal\Core\Command\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>
Hierarchy
- class \Symfony\Component\Console\Command\Command
- class \Composer\Command\BaseCommand extends \Symfony\Component\Console\Command\Command
- class \Composer\Command\InstallCommand extends \Composer\Command\BaseCommand uses \Composer\Command\CompletionTrait
- class \Composer\Command\BaseCommand extends \Symfony\Component\Console\Command\Command
Expanded class hierarchy of InstallCommand
File
-
vendor/
composer/ composer/ src/ Composer/ Command/ InstallCommand.php, line 31
Namespace
Composer\CommandView source
class InstallCommand extends BaseCommand {
use CompletionTrait;
/**
* @return void
*/
protected function configure() {
$this->setName('install')
->setAliases([
'i',
])
->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json')
->setDefinition([
new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist (default behavior).'),
new InputOption('prefer-install', null, InputOption::VALUE_REQUIRED, 'Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).', null, $this->suggestPreferInstall()),
new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
new InputOption('download-only', null, InputOption::VALUE_NONE, 'Download only, do not install packages.'),
new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
new InputOption('audit', null, InputOption::VALUE_NONE, 'Run an audit after installation is complete.'),
new InputOption('audit-format', null, InputOption::VALUE_REQUIRED, 'Audit output format. Must be "table", "plain", "json", or "summary".', Auditor::FORMAT_SUMMARY, Auditor::FORMATS),
new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
])
->setHelp(<<<EOT
The <info>install</info> command reads the composer.lock file from
the current directory, processes it, and downloads and installs all the
libraries and dependencies outlined in that file. If the file does not
exist it will look for composer.json and do the same.
<info>php composer.phar install</info>
Read more at https://getcomposer.org/doc/03-cli.md#install-i
EOT
);
}
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();
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
BaseCommand::$composer | private | property | ||||
BaseCommand::$io | private | property | ||||
BaseCommand::complete | public | function | @inheritdoc | Overrides Command::complete | 1 | |
BaseCommand::createComposerInstance | protected | function | Calls { | |||
BaseCommand::formatRequirements | protected | function | ||||
BaseCommand::getApplication | public | function | Gets the application instance for this command. | Overrides Command::getApplication | ||
BaseCommand::getAuditFormat | protected | function | @internal | |||
BaseCommand::getComposer | Deprecated | public | function | |||
BaseCommand::getIO | public | function | ||||
BaseCommand::getPlatformRequirementFilter | protected | function | ||||
BaseCommand::getPreferredInstallOptions | protected | function | Returns preferSource and preferDist values based on the configuration. | |||
BaseCommand::getTerminalWidth | protected | function | ||||
BaseCommand::initialize | protected | function | @inheritDoc | Overrides Command::initialize | 1 | |
BaseCommand::isProxyCommand | public | function | Whether or not this command is meant to call another command. | 2 | ||
BaseCommand::normalizeRequirements | protected | function | ||||
BaseCommand::renderTable | protected | function | ||||
BaseCommand::resetComposer | public | function | Removes the cached composer instance | |||
BaseCommand::setComposer | public | function | ||||
BaseCommand::setIO | public | function | ||||
BaseCommand::tryComposer | public | function | Retrieves the default Composer\Composer instance or null | |||
Command::$aliases | private | property | 1 | |||
Command::$application | private | property | ||||
Command::$code | private | property | ||||
Command::$definition | private | property | ||||
Command::$description | private | property | 1 | |||
Command::$fullDefinition | private | property | ||||
Command::$help | private | property | ||||
Command::$helperSet | private | property | ||||
Command::$hidden | private | property | ||||
Command::$ignoreValidationErrors | private | property | 2 | |||
Command::$name | private | property | ||||
Command::$processTitle | private | property | ||||
Command::$synopsis | private | property | ||||
Command::$usages | private | property | ||||
Command::addArgument | public | function | Adds an argument. | 2 | ||
Command::addOption | public | function | Adds an option. | 2 | ||
Command::addUsage | public | function | Add a command usage example, it'll be prefixed with the command name. | 2 | ||
Command::FAILURE | public | constant | ||||
Command::getAliases | public | function | Returns the aliases for the command. | |||
Command::getDefaultDescription | public static | function | ||||
Command::getDefaultName | public static | function | ||||
Command::getDefinition | public | function | Gets the InputDefinition attached to this Command. | 2 | ||
Command::getDescription | public | function | Returns the description for the command. | |||
Command::getHelp | public | function | Returns the help for the command. | 2 | ||
Command::getHelper | public | function | Gets a helper instance by name. | 2 | ||
Command::getHelperSet | public | function | Gets the helper set. | 1 | ||
Command::getName | public | function | Returns the command name. | |||
Command::getNativeDefinition | public | function | Gets the InputDefinition to be used to create representations of this Command. | 2 | ||
Command::getProcessedHelp | public | function | Returns the processed help for the command replacing the %command.name% and %command.full_name% patterns with the real values dynamically. |
2 | ||
Command::getSynopsis | public | function | Returns the synopsis for the command. | 2 | ||
Command::getUsages | public | function | Returns alternative usages of the command. | 2 | ||
Command::ignoreValidationErrors | public | function | Ignores validation errors. | 2 | ||
Command::interact | protected | function | Interacts with the user. | 5 | ||
Command::INVALID | public | constant | ||||
Command::isEnabled | public | function | Checks whether the command is enabled or not in the current environment. | 2 | ||
Command::isHidden | public | function | ||||
Command::mergeApplicationDefinition | public | function | Merges the application definition with the command definition. | 2 | ||
Command::run | public | function | Runs the command. | 4 | ||
Command::setAliases | public | function | Sets the aliases for the command. | |||
Command::setApplication | public | function | 2 | |||
Command::setCode | public | function | Sets the code to execute when running this command. | 2 | ||
Command::setDefinition | public | function | Sets an array of argument and option instances. | 2 | ||
Command::setDescription | public | function | Sets the description for the command. | |||
Command::setHelp | public | function | Sets the help for the command. | 2 | ||
Command::setHelperSet | public | function | 2 | |||
Command::setHidden | public | function | ||||
Command::setName | public | function | Sets the name of the command. | |||
Command::setProcessTitle | public | function | Sets the process title of the command. | 2 | ||
Command::SUCCESS | public | constant | ||||
Command::validateName | private | function | Validates a command name. | |||
Command::__construct | public | function | 15 | |||
CompletionTrait::requireComposer | abstract public | function | ||||
CompletionTrait::suggestAvailablePackage | private | function | Suggest package names available on all configured repositories. | |||
CompletionTrait::suggestAvailablePackageInclPlatform | private | function | Suggest package names available on all configured repositories or platform packages from the ones available on the currently-running PHP |
|||
CompletionTrait::suggestInstalledPackage | private | function | Suggest package names from installed. | |||
CompletionTrait::suggestInstalledPackageTypes | private | function | Suggest package names from installed. | |||
CompletionTrait::suggestPlatformPackage | private | function | Suggest platform packages from the ones available on the currently-running PHP | |||
CompletionTrait::suggestPreferInstall | private | function | Suggestion values for "prefer-install" option | |||
CompletionTrait::suggestRootRequirement | private | function | Suggest package names from root requirements. | |||
InstallCommand::configure | protected | function | Overrides Command::configure | |||
InstallCommand::execute | protected | function | Executes the current command. | Overrides Command::execute |