Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Composer/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ protected function configure()
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not output suggested packages.'),
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')
))
Expand Down Expand Up @@ -86,6 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->setPreferSource($preferSource)
->setPreferDist($preferDist)
->setDevMode(!$input->getOption('no-dev'))
->setNoSuggest($input->getOption('no-dev') || $input->getOption('no-suggest'))
->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))
;
Expand Down
2 changes: 2 additions & 0 deletions src/Composer/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected function configure()
new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Disables all custom installers.'),
new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'Do not output suggested packages..'),
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')
))
Expand Down Expand Up @@ -90,6 +91,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->setPreferSource($preferSource)
->setPreferDist($preferDist)
->setDevMode(!$input->getOption('no-dev'))
->setNoSuggest($input->getOption('no-suggest'))
->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))
->setUpdate(true)
Expand Down
32 changes: 24 additions & 8 deletions src/Composer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class Installer
protected $optimizeAutoloader = false;
protected $devMode = false;
protected $dryRun = false;
protected $noSuggest = false;
protected $verbose = false;
protected $update = false;
protected $runScripts = true;
Expand Down Expand Up @@ -215,16 +216,18 @@ public function run()
}
$this->installationManager->notifyInstalls();

// output suggestions
foreach ($this->suggestedPackages as $suggestion) {
$target = $suggestion['target'];
foreach ($installedRepo->getPackages() as $package) {
if (in_array($target, $package->getNames())) {
continue 2;
// output suggestions only --no-suggest is not set
if (!$this->noSuggest) {
foreach ($this->suggestedPackages as $suggestion) {
$target = $suggestion['target'];
foreach ($installedRepo->getPackages() as $package) {
if (in_array($target, $package->getNames())) {
continue 2;
}
}
}

$this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
$this->io->write($suggestion['source'].' suggests installing '.$suggestion['target'].' ('.$suggestion['reason'].')');
}
}

if (!$this->dryRun) {
Expand Down Expand Up @@ -1001,6 +1004,19 @@ public function setVerbose($verbose = true)
return $this;
}

/**
* Do not show suggested packages.
*
* @param boolean $noSuggest
* @return Installer
*/
public function setNoSuggest($noSuggest = true)
{
$this->noSuggest = $noSuggest;

return $this;
}

/**
* restrict the update operation to a few packages, all other packages
* that are already installed will be kept at their current version
Expand Down
29 changes: 29 additions & 0 deletions tests/Composer/Test/Fixtures/installer/suggest-disabled.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
--TEST--
Suggestions are not displayed if --no-suggest is used.
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "a/a", "version": "1.0.0", "suggest": { "b/b": "an obscure reason" } },
{ "name": "c/c", "version": "1.0.0", "replace": { "b/b": "1.0.0" } }
]
}
],
"require": {
"a/a": "1.0.0",
"b/b": "1.0.0"
}
}
--RUN--
install --no-suggest
--EXPECT-OUTPUT--
<info>Loading composer repositories with package information</info>
<info>Installing dependencies</info>
<info>Writing lock file</info>
<info>Generating autoload files</info>

--EXPECT--
Installing a/a (1.0.0)
Installing c/c (1.0.0)