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
17 changes: 12 additions & 5 deletions src/Composer/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,11 +467,18 @@ protected function doInstall($localRepo, $installedRepo, $platformRepo, $aliases
$this->processDevPackages($localRepo, $pool, $policy, $repositories, $installedRepo, $lockedRepository, 'force-links');

// solve dependencies
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
$solver = new Solver($policy, $pool, $installedRepo, $this->io);
try {
$operations = $solver->solve($request, $this->ignorePlatformReqs);
} catch (SolverProblemsException $e) {
for ($runSolver = true, $solverRuns = 0; $runSolver && $solverRuns < 5; $solverRuns++) {
$this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $this->devMode, $policy, $pool, $installedRepo, $request);
$solver = new Solver($policy, $pool, $installedRepo, $this->io);
try {
$operations = $solver->solve($request, $this->ignorePlatformReqs);
$e = null;
$runSolver = false;
} catch (SolverProblemsException $e) {
$runSolver = $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::DEPENDENCIES_SOLVING_PROBLEM, $this->devMode, $policy, $pool, $installedRepo, $request);
}
}
if ($e) {
$this->io->writeError('<error>Your requirements could not be resolved to an installable set of packages.</error>', true, IOInterface::QUIET);
$this->io->writeError($e->getMessage());
if ($this->update && !$this->devMode) {
Expand Down
15 changes: 15 additions & 0 deletions src/Composer/Installer/InstallerEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,19 @@ class InstallerEvents
* @var string
*/
const POST_DEPENDENCIES_SOLVING = 'post-dependencies-solving';

/**
* The DEPENDENCIES_SOLVING_PROBLEM event occurs after resolve operations
* when an installable set of packages was not found.
*
* The event listener method receives a
* Composer\Installer\InstallerEvent instance.
*
* If the listener returns TRUE, it indicates that the listener has made
* modifications to Composer's state that may allow an installable set of
* packages to be found, and resolve operations should be retried.
*
* @var string
*/
const DEPENDENCIES_SOLVING_PROBLEM = 'dependencies-solving-problem';
}