Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP: organise controllers in subfolders

Tags:

cakephp-2.0

Is it possible in CakePHP to organise controllers (and models) in subfolders? Thanks.

like image 388
entropid Avatar asked Jan 12 '12 13:01

entropid


2 Answers

It's not deprecated at all. You can accomplish this using the App:build and point to your subfolders. For example, if you want to put all of your Twitter models in Model/Twitter to keep your code organized, you can add the following to the bootstrap.php:

App::build(array(
    'Model' => array(APP . 'Model' . DS . 'Twitter' . DS),
));

Now, any model file you put in Model/Twitter will be available when you call it.

See more here: http://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::build

like image 84
Chuck Burgess Avatar answered Oct 02 '22 19:10

Chuck Burgess


Yes you can, but it is deprecated. See the discussion here. The last post on this page describes how to do it in the bootstrap.

like image 35
David Bauer Avatar answered Oct 02 '22 19:10

David Bauer