How to use multiple AppModels?

Published on and tagged with cakephp  tip

CakePHP supports just one custom AppModel, which must be placed in the /app folder. If you place another AppModel in the app folder and you try to extend your model from that AppModel, you get a “Class not found” error. To avoid that error you simply have to add a require statement at the top of your model:

require(APP . 'my_special_app_model.php');

class MyModel extends MySpecialAppModel

The same approach works also for AppControllers.

2 comments baked

© daniel hofstetter. Licensed under a Creative Commons License