All “load” functions & listClasses() are now deprecated

Published on and tagged with cakephp

Recently, all “load” functions, like loadModel() or loadHelper(), plus the listClasses() function, all defined in /cake/basics.php, have been deprecated. Those functions still work, but you will get a warning when using them. Instead of the “load” functions you now have to use:

App::import('Model', $modelName);
App::import('Helper', $helperName);

The replacement for the listClasses() function is:

Configure::listObjects('file', $path);

If you use somewhere in your code the functions loadControllers() or loadModels() (without any parameters), then you can combine the two aforementioned approaches:

App::import('Controller', Configure::listObjects('controller'));
App::import('Model', Configure::listObjects('model'));

Something that may lead to problems is the way you have to specify the $type parameter for those two functions: Configure::listObjects() expects the $type to be lowercase (e.g. “model”) whereas App::import() expects the first character to be uppercase (e.g. “Model”)…

9 comments baked

  • Zonium

    Some other notable additions / changes posted in Google group by gwoo:

    It seems these changes are in early alpha state. I cant convince myself to try/use them for production :)

  • cakebaker

    @Zonium: Thanks for your comment!

    And yes, it is probably a bit risky to use them in production yet.

  • Beth

    I’ve decided to take a break from cake until 1.2 is finalized.

    All the deprecated functionality is becoming a headache because of the 3rd party goodies I depend on. The other reason is there has been a definite degradation in performance.

    Baker’s should have called it version 2.0 which is more appropriate IMHO.

  • cakebaker

    @Beth: Thanks for your comment!

    I use the edge version only for pet projects, else I use the latest release.

    I think the Cake team should have done some stable 1.2 releases, each adding a set of new features. Staying at the alpha level for such a long time is bad…

  • Rick

    Two things about CakePHP that are bothering me:

    1) The ever changing API, that will always have a 20+ deprecated functions with each release. And it’s already hard for newcomers to learn using the framework with only the limited documentation provided on the website (no, random articles that I call “how to implement x-component/helper” articles won’t suffice, neither will the very very incomplete “manual”). Cake needs a structured and complete guide.

    2) The API Documentation, that is incomplete and simply unusable as a reference in its current state. If you have ever seen the DirectX SDK Documentation or the Qt SDK Documentation, wherein every function parameter and all the possible return values are documented, you’ll see why I find CakePHPs “doxygenerated” API docs lacking.

  • cakebaker

    @Rick: Thanks for your comment!

    1) Well, officially cake 1.2 is still considered as alpha (resp. pre-beta) version, so you cannot expect the API to be stable. On the other hand there is no alternative to 1.2, as the 1.1.x.x version is a dead-end. I agree with you, that cake needs a structured and complete guide.

    2) Yes, the API documentation could be improved (or the API itself so that less documentation is needed). And I agree with you that it is rather unusable, so I usually look directly in the source.

  • speedmax

    For any large application eg cms, shopping cart, its is normal to have a lot of Models from tables or Multiple Models derived from same table.

    App::import() has a undocumented feature.

    Now you can use folder to organize models, since it search for Model in app/models folder recursively and remember its path inside a cache. package them up

    for example


    You guys should take advantage of this to make your app extra organized.

    PS: dho you could do it in NoseRub.

  • Tim Daldini

    Whoops, I just noticed shortcut functions like am/low etc are being removed from the core. -If- they really will not be usable anymore by the next release it will be quite a task getting projects up to date.

    I hope I’m wrong.

  • cakebaker

    @speedmax, Tim: Thanks for your comments!

    @speedmax: Yes, this is a nice new feature, I wrote about this feature in Organizing your code with folders.

    In NoseRub we cannot use this feature yet as it is not available in the pre-beta release of cake we currently use.

    @Tim: I don’t know if these functions get deprecated. And even if they get removed, it should be easy to re-add them in app/config/bootstrap.php so you do not have to change all your code.

© daniel hofstetter. Licensed under a Creative Commons License