We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Class ControllerBase not found

Hi,

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

Can you please help with this?

Thanks, Razvan!



13.8k
Accepted
answer
edited Apr '17

How does your IndexController.php file looks like? Because the error is about IndexController.php line 3 and not AuthController.php line 3.

Because otherwise what you are doing is the correct way.

This basically means that ControllerBase is not loaded with loader.



5.7k
edited Apr '17

IndexController.php

<?php

class IndexController extends \ControllerBase
{
    public function indexAction()
    {

    }
}


13.8k

This worked?

IndexController.php

<?php

class IndexController extends \ControllerBase
{
   public function indexAction()
   {

   }
}


5.7k

This worked?

IndexController.php

<?php

class IndexController extends \ControllerBase
{
   public function indexAction()
   {

   }
}

Yes it worked but I needed to setup the routes. /:controller, namespace, controller:1 and action:index. Thank you!