From d9909993b24cb64c8519c15612cfbe7b4617e96e Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Wed, 11 May 2016 17:16:08 +0200 Subject: [PATCH] Add --prefer-stable and --prefer-lowest to "require" command Fixes #5314 --- doc/03-cli.md | 3 +++ src/Composer/Command/RequireCommand.php | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/doc/03-cli.md b/doc/03-cli.md index 6318a5a6e..d6aca2291 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -195,6 +195,9 @@ php composer.phar require vendor/package:2.* vendor/package2:dev-master can take a bit of time to run so it is currently not done by default. * **--classmap-authoritative (-a):** Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`. +* **--prefer-stable:** Prefer stable versions of dependencies. +* **--prefer-lowest:** Prefer lowest versions of dependencies. Useful for testing minimal + versions of requirements, generally used with `--prefer-stable`. ## remove diff --git a/src/Composer/Command/RequireCommand.php b/src/Composer/Command/RequireCommand.php index 88adeff92..c8aeb7cef 100644 --- a/src/Composer/Command/RequireCommand.php +++ b/src/Composer/Command/RequireCommand.php @@ -47,6 +47,8 @@ class RequireCommand extends InitCommand new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'), new InputOption('update-with-dependencies', null, InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies.'), new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore platform requirements (php & ext- packages).'), + new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'), + new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'), new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'), 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`.'), @@ -162,6 +164,8 @@ EOT ->setUpdateWhitelist(array_keys($requirements)) ->setWhitelistDependencies($input->getOption('update-with-dependencies')) ->setIgnorePlatformRequirements($input->getOption('ignore-platform-reqs')) + ->setPreferStable($input->getOption('prefer-stable')) + ->setPreferLowest($input->getOption('prefer-lowest')) ; $exception = null;