mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 14:28:27 +08:00
Fix #18656: Added ability for yii serve
's --router
param to take an alias
This commit is contained in:
@ -19,6 +19,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #18648: Fix `yii\web\Request` to properly handle HTTP Basic Auth headers (olegbaturin)
|
- Bug #18648: Fix `yii\web\Request` to properly handle HTTP Basic Auth headers (olegbaturin)
|
||||||
- Enh #18726: Added `yii\helpers\Json::$prettyPrint` (rhertogh)
|
- Enh #18726: Added `yii\helpers\Json::$prettyPrint` (rhertogh)
|
||||||
- Enh #18734: Added `yii\validators\EmailValidator::$enableLocalIDN` (brandonkelly)
|
- Enh #18734: Added `yii\validators\EmailValidator::$enableLocalIDN` (brandonkelly)
|
||||||
|
- Enh #18656: Added ability for `yii serve`'s `--router` param to take an alias (markhuot)
|
||||||
|
|
||||||
|
|
||||||
2.0.42.1 May 06, 2021
|
2.0.42.1 May 06, 2021
|
||||||
|
@ -36,7 +36,7 @@ class ServeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public $docroot = '@app/web';
|
public $docroot = '@app/web';
|
||||||
/**
|
/**
|
||||||
* @var string path to router script.
|
* @var string path or [path alias](guide:concept-aliases) to router script.
|
||||||
* See https://secure.php.net/manual/en/features.commandline.webserver.php
|
* See https://secure.php.net/manual/en/features.commandline.webserver.php
|
||||||
*/
|
*/
|
||||||
public $router;
|
public $router;
|
||||||
@ -52,6 +52,7 @@ class ServeController extends Controller
|
|||||||
public function actionIndex($address = 'localhost')
|
public function actionIndex($address = 'localhost')
|
||||||
{
|
{
|
||||||
$documentRoot = Yii::getAlias($this->docroot);
|
$documentRoot = Yii::getAlias($this->docroot);
|
||||||
|
$router = $this->router !== null ? Yii::getAlias($this->router) : null;
|
||||||
|
|
||||||
if (strpos($address, ':') === false) {
|
if (strpos($address, ':') === false) {
|
||||||
$address = $address . ':' . $this->port;
|
$address = $address . ':' . $this->port;
|
||||||
@ -67,19 +68,19 @@ class ServeController extends Controller
|
|||||||
return self::EXIT_CODE_ADDRESS_TAKEN_BY_ANOTHER_PROCESS;
|
return self::EXIT_CODE_ADDRESS_TAKEN_BY_ANOTHER_PROCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->router !== null && !file_exists($this->router)) {
|
if ($this->router !== null && !file_exists($router)) {
|
||||||
$this->stdout("Routing file \"$this->router\" does not exist.\n", Console::FG_RED);
|
$this->stdout("Routing file \"$router\" does not exist.\n", Console::FG_RED);
|
||||||
return self::EXIT_CODE_NO_ROUTING_FILE;
|
return self::EXIT_CODE_NO_ROUTING_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->stdout("Server started on http://{$address}/\n");
|
$this->stdout("Server started on http://{$address}/\n");
|
||||||
$this->stdout("Document root is \"{$documentRoot}\"\n");
|
$this->stdout("Document root is \"{$documentRoot}\"\n");
|
||||||
if ($this->router) {
|
if ($this->router) {
|
||||||
$this->stdout("Routing file is \"$this->router\"\n");
|
$this->stdout("Routing file is \"$router\"\n");
|
||||||
}
|
}
|
||||||
$this->stdout("Quit the server with CTRL-C or COMMAND-C.\n");
|
$this->stdout("Quit the server with CTRL-C or COMMAND-C.\n");
|
||||||
|
|
||||||
passthru('"' . PHP_BINARY . '"' . " -S {$address} -t \"{$documentRoot}\" $this->router");
|
passthru('"' . PHP_BINARY . '"' . " -S {$address} -t \"{$documentRoot}\" $router");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user