簡體   English   中英

別名“custom.controllers.ExampleController.php”無效

[英]Alias “custom.controllers.ExampleController.php” is invalid

這是錯誤:

別名“custom.controllers.ExampleController.php”無效。 確保它指向現有的PHP文件,並且該文件是可讀的。

我的代碼如下

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' => 'custom\controllers\Product.php',

(在你的代碼中沒有ExampleController ..)

見p 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編碼標准建議

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM