Har*_*chu 7 php console-application yii yii1.x
如何在YII CConsoleApplication应用程序中获取基本URL.
我尝试了'Yii :: app() - > request-> getBaseUrl(true)'并最终出现以下错误.
__PRE__
Asg*_*oth 13
控制台应用程序中没有请求对象.Web应用程序中的请求对象是CHttpRequest的实例,如果要在脱机任务中生成URL,则必须以其他方式配置baseUrl,可能在配置中:
"request" => array(
'hostInfo' => 'http://localhost',
'baseUrl' => '/yii-project/index-test.php',
),
// OR
'request' => array(
'hostInfo' => 'http://localhost',
'baseUrl' => '/yii-project',
'scriptUrl' => 'index-test.php',
),
Run Code Online (Sandbox Code Playgroud)