1
0
Fork 0

Allow global ignore-platform-req (#10616)

pull/11010/head
Yehuda Katz 2022-03-15 10:29:25 -04:00 committed by GitHub
parent d584a259f6
commit c3a41b944e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -1174,3 +1174,11 @@ useful for plugin authors to identify what is firing when exactly.
If set to `1`, it is the equivalent of passing the `--no-dev` argument to `install` or If set to `1`, it is the equivalent of passing the `--no-dev` argument to `install` or
`update`. You can override this for a single command by setting `COMPOSER_NO_DEV=0`. `update`. You can override this for a single command by setting `COMPOSER_NO_DEV=0`.
### COMPOSER_IGNORE_PLATFORM_REQ or COMPOSER_IGNORE_PLATFORM_REQS
If `COMPOSER_IGNORE_PLATFORM_REQS` set to `1`, it is the equivalent of passing the `--ignore-platform-reqs` argument.
Otherwise, specifying a comma separated list in `COMPOSER_IGNORE_PLATFORM_REQ` will ignore those specific requirements.
For example, if a development workstation will never run database queries, this can be used to ignore the requirement for the database extensions to be available.
If you set `COMPOSER_IGNORE_PLATFORM_REQ=ext-oci8`, then composer will allow packages to be installed even if the `oci8` PHP extension is not enabled.

View File

@ -198,6 +198,8 @@ abstract class BaseCommand extends Command
} }
$composer = $this->tryComposer($disablePlugins, $disableScripts); $composer = $this->tryComposer($disablePlugins, $disableScripts);
$io = $this->getIO();
if (null === $composer) { if (null === $composer) {
$composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts); $composer = Factory::createGlobal($this->getIO(), $disablePlugins, $disableScripts);
} }
@ -210,12 +212,29 @@ abstract class BaseCommand extends Command
$input->setOption('no-progress', true); $input->setOption('no-progress', true);
} }
if (true == $input->hasOption('no-dev')) { if (true === $input->hasOption('no-dev')) {
if (!$input->getOption('no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) { if (!$input->getOption('no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) {
$input->setOption('no-dev', true); $input->setOption('no-dev', true);
} }
} }
if (true === $input->hasOption('ignore-platform-reqs')) {
if (!$input->getOption('ignore-platform-reqs') && true == Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQS')) {
$input->setOption('ignore-platform-reqs', true);
$io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>');
}
}
if (true === $input->hasOption('ignore-platform-req') && (!$input->hasOption('ignore-platform-reqs') || !$input->getOption('ignore-platform-reqs'))) {
$ignorePlatformReqEnv = Platform::getEnv('COMPOSER_IGNORE_PLATFORM_REQ');
if (0 === count($input->getOption('ignore-platform-req')) && is_string($ignorePlatformReqEnv) && '' !== $ignorePlatformReqEnv) {
$input->setOption('ignore-platform-req', explode(',', $ignorePlatformReqEnv));
$io->writeError('<warning>COMPOSER_IGNORE_PLATFORM_REQ is set to ignore '.$ignorePlatformReqEnv.'. You may experience unexpected errors.</warning>');
}
}
parent::initialize($input, $output); parent::initialize($input, $output);
} }