别名 "custom.controllers.ExampleController.php" 无效
Alias "custom.controllers.ExampleController.php" is invalid
这是错误:
Alias "custom.controllers.ExampleController.php" is invalid. Make sure
it points to an existing PHP file and the file is readable.
我的代码如下
main.php=>
return
array(
'controllerMap' => array(
'product' => array(
'class' => 'custom.controllers.Product.php',
),
),
'import' => array(
'custom.mycompany.*',
),
'components' =>
array(
'widgetHandler' => array(
//Load a component
'class' => 'custom.mycompany.mywidget.mywidget',
),
)
);
Product.php=>
<?php
class Product extends Controller
{
public function actionIndex()
{
echo "this is the default index function";
}
public function actionTest()
{
echo "This is the test function";
}
}
我正在使用 lightspeed cms。
Yii2 的表示法/php class 不是基于点而是基于斜线
'class' => 'custom\controllers\Product.php',
(并且在您的代码中没有 ExampleController..)
见第 https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
和https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
https://github.com/yiisoft/yii2/blob/master/docs/internals/core-code-style.md
对于 PHP Yii2 编码标准建议
这是错误:
Alias "custom.controllers.ExampleController.php" is invalid. Make sure it points to an existing PHP file and the file is readable.
我的代码如下
main.php=>
return
array(
'controllerMap' => array(
'product' => array(
'class' => 'custom.controllers.Product.php',
),
),
'import' => array(
'custom.mycompany.*',
),
'components' =>
array(
'widgetHandler' => array(
//Load a component
'class' => 'custom.mycompany.mywidget.mywidget',
),
)
);
Product.php=>
<?php
class Product extends Controller
{
public function actionIndex()
{
echo "this is the default index function";
}
public function actionTest()
{
echo "This is the test function";
}
}
我正在使用 lightspeed cms。
Yii2 的表示法/php class 不是基于点而是基于斜线
'class' => 'custom\controllers\Product.php',
(并且在您的代码中没有 ExampleController..)
见第 https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
和https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md
https://github.com/yiisoft/yii2/blob/master/docs/internals/core-code-style.md
对于 PHP Yii2 编码标准建议