1

This is the error:

Alias "custom.controllers.ExampleController.php" is invalid. Make sure it points to an existing PHP file and the file is readable.

My code is given below

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";
    }
}

I am using lightspeed cms.

Abhishek Gupta
  • 109
  • 1
  • 7

1 Answers1

0

the notation for Yii2 / php class is not dot based but slash based

   'class' => 'custom\controllers\Product.php',

(And in your code there is not the ExampleController..)

see p https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md

and 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

for PHP an Yii2 coding standard suggestion

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107