1
votes

I tried to extend ControllerBase class from AuthController but this is happen: Fatal error: Class 'ControllerBase' not found C:\xampp\htdocs\tc\app\controllers\IndexController.php on line 3 .

ControllerBase.php

<?php

use Phalcon\Mvc\Controller;

class ControllerBase extends Controller { 

    public function onConstruct() {

    }

}

AuthController.php

<?php

class AuthController extends ControllerBase {

    public function indexAction()
    {

    }
 }

It is there a problem? I use PhpStorm and I added ExternalLibraries from C:\phalcon-devtools-master\ide\stubs\Phalcon

Could you please help with this?

Thanks, Razvan!

2
where is the IndexController? - hassan

2 Answers

0
votes

may be extends \Phalcon\Mvc\Controller

in example show "ControllerBase" if use "use Phalcon\Mvc\Controller;"

ControllerBase not exist in phalcon

0
votes

Try to use namespaces and register them with Phalcon loader.

For example in ControllerBase:

namespace \Base\Frontend\Controllers;

use \Phalcon\Mvc\Controller;

class ControllerBase extends Controller;

In IndexController:

namespace \Base\Frontend\Controllers;

class IndexController extends ControllerBase;

and in services or module config add:

$loader = new \Phalcon\Loader();

$loader->registerNamespaces(array(
    'Base\Frontend\Controllers' => __DIR__ . '/controllers/'
));

$loader->register();

where __DIR__ . '/controllers/' is the path to your controllers directory.