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

Models namespace probleme on scaffold - Class 'ControllerBase' not found

Hello everybody, I'm using Phalcon 1.3.4. I create a project test in multiple mode using this command line:

phalcon create-project test --type=modules

and i generate crud with this command line :

phalcon scaffold --table-name=users

And when i execute 127.0.0.1/test/users i got this error : Fatal error: Class 'ControllerBase' not found in C:\xampp\htdocs\test\apps\frontend\controllers\UsersController.php on line 7

There is a probleme with namespaces. I change command line for generating crud by this :

phalcon scaffold --table-name=users --ns-controllers=Test\Frontend\Controllers --ns-models=Test\Frontend\Models

Now 127.0.0.1/test/users work but when i clic on serach i got this message error : Fatal error: Class 'Users' not found in C:\xampp\htdocs\test\apps\frontend\controllers\UsersController.php on line 26

I thins that the probleme came from model namespace ! Anyone know how tu resolve this problem ?

Thank you.

edited Apr '15

Yeah, same here. So my solution is to avoid using namespace for models. In the controller itself, whenever I want to refer to a model, I would use \Users instead of Users, just my two cents.

edited Apr '16

Make sure you have this in ControllerBase :

namespace Test\Frontend\Controllers;
use Phalcon\Mvc\Controller;
class ControllerBase extends Controller

and this in UsersController :

namespace Test\Frontend\Controllers;
use Test\Frontend\Models\Users as Users;
class PageController extends ControllerBase

I encountered the same problem and solved it with correcting namespaces and aliasing the model. I used the latest devtools on Phalcon 2.0.9.