From 6bb488de6bac9904d1310cd5e45bc8a0d0df0c95 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 30 Oct 2017 09:33:22 +0100 Subject: [PATCH 1/2] search for framework path in requirements.php fixes https://github.com/yiisoft/yii2/issues/15041 --- requirements.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/requirements.php b/requirements.php index 5d19732..356773a 100644 --- a/requirements.php +++ b/requirements.php @@ -11,7 +11,22 @@ */ // you may need to adjust this path to the correct Yii framework path -$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2'; +// uncomment and adjust the following line if Yii is not located at the default path +//$frameworkPath = dirname(__FILE__) . '/vendor/yiisoft/yii2'; + + +if (!isset($frameworkPath)) { + $searchPaths = [ + dirname(__FILE__) . '/vendor/yiisoft/yii2', + dirname(__FILE__) . '/../vendor/yiisoft/yii2', + ]; + foreach($searchPaths as $path) { + if (is_dir($path)) { + $frameworkPath = $path; + break; + } + } +} if (!is_dir($frameworkPath)) { echo '

Error

'; From 1c4072499f3d38e9ee2fbeb8702ad57ab596a604 Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Mon, 30 Oct 2017 09:42:15 +0100 Subject: [PATCH 2/2] improved requirements checker error message about framework --- requirements.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/requirements.php b/requirements.php index 356773a..91a0fb0 100644 --- a/requirements.php +++ b/requirements.php @@ -28,11 +28,19 @@ if (!isset($frameworkPath)) { } } -if (!is_dir($frameworkPath)) { - echo '

Error

'; - echo '

The path to yii framework seems to be incorrect.

'; - echo '

You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . '.

'; - echo '

Please refer to the README on how to install Yii.

'; +if (!isset($frameworkPath) || !is_dir($frameworkPath)) { + $message = "

Error

\n\n" + . "

The path to yii framework seems to be incorrect.

\n" + . '

You need to install Yii framework via composer or adjust the framework path in file ' . basename(__FILE__) . ".

\n" + . '

Please refer to the README on how to install Yii.

\n"; + + if (!empty($_SERVER['argv'])) { + // do not print HTML when used in console mode + echo strip_tags($message); + } else { + echo $message; + } + exit(1); } require_once($frameworkPath . '/requirements/YiiRequirementChecker.php');