Merge remote-tracking branch 'singles/missing-extension-ini-hint'
commit
4d9bab4b86
|
@ -31,14 +31,23 @@ class SolverProblemsException extends \RuntimeException
|
||||||
protected function createMessage()
|
protected function createMessage()
|
||||||
{
|
{
|
||||||
$text = "\n";
|
$text = "\n";
|
||||||
|
$hasExtensionProblems = false;
|
||||||
foreach ($this->problems as $i => $problem) {
|
foreach ($this->problems as $i => $problem) {
|
||||||
$text .= " Problem ".($i + 1).$problem->getPrettyString($this->installedMap)."\n";
|
$text .= " Problem ".($i + 1).$problem->getPrettyString($this->installedMap)."\n";
|
||||||
|
|
||||||
|
if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
|
||||||
|
$hasExtensionProblems = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($text, 'could not be found') || strpos($text, 'no matching package found')) {
|
if (strpos($text, 'could not be found') || strpos($text, 'no matching package found')) {
|
||||||
$text .= "\nPotential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.\n\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
|
$text .= "\nPotential causes:\n - A typo in the package name\n - The package is not available in a stable-enough version according to your minimum-stability setting\n see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.\n\nRead <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($hasExtensionProblems) {
|
||||||
|
$text .= $this->createExtensionHint();
|
||||||
|
}
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,4 +55,40 @@ class SolverProblemsException extends \RuntimeException
|
||||||
{
|
{
|
||||||
return $this->problems;
|
return $this->problems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function createExtensionHint()
|
||||||
|
{
|
||||||
|
$paths = array();
|
||||||
|
|
||||||
|
if (($iniPath = php_ini_loaded_file()) !== false) {
|
||||||
|
$paths[] = $iniPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined('HHVM_VERSION') && $additionalIniPaths = php_ini_scanned_files()) {
|
||||||
|
$paths = array_merge($paths, array_map("trim", explode(",", $additionalIniPaths)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($paths) === 0) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = "\n Because of missing extensions, please verify whether they are enabled in those .ini files:\n - ";
|
||||||
|
$text .= implode("\n - ", $paths);
|
||||||
|
$text .= "\n You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function hasExtensionProblems(array $reasonSets)
|
||||||
|
{
|
||||||
|
foreach ($reasonSets as $reasonSet) {
|
||||||
|
foreach($reasonSet as $reason) {
|
||||||
|
if (isset($reason["rule"]) && 0 === strpos($reason["rule"]->getRequiredPackage(), 'ext-')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue