Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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!



5.0k
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.



1.6k
edited Apr '17

IndexController.php

<?php

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

    }
}


5.0k

This worked?

IndexController.php

<?php

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

   }
}


1.6k

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!