views:

253

answers:

2

After introduction of Autoloader, I started to port existing ZF app. The immediate error was that IndexController was extended by BaseController, which is now cannot be found, although it resides in application/controllers folder, with other controllers.

Does the autoloader paradigm require that BaseController is renamed to My_BaseController and put into library folder? On the other hand, it's so nice to keep all controllers in one folder with a BaseController.

A: 

I haven't actually seen anything use application/controllers before

Generally, stuff would go into application/modules/<module>/controllers/ where "generic" controllers would go into the default module

You might get a better answer if the above is incorrect if you mention what versions your transitioning between, and how you're trying to call the controller?

Mez
@Mez: all my application use the `application/controllers` layout, never coded anything with a module and I think the first time I got that directory scheme was buy using Zend Studio
RageZ
Transitioning 1.7.7 and 1.9.1. So the best practice is to use default module even if the app contains only 1 module?This is generally a basic app that has grown from main ZF tutorial app. The code is "class IndexController extends My_BaseController" and index controller is simply invoked from zfapp/index URL. I assume that FrontController with it's dispatch() sends user to IndexController. Then error occurs.
PHP thinker
Create a new project with ZF Tool and there ist an application/controllers directory. And NO Module directory. Same for autoloading : Default has to be direct under application.
ArneRie
+4  A: 

The module autoloader does not load from the Controller's folder by default. You can either add the folder to the included Module autoloader or create your own resource autoloader.

See http://framework.zend.com/manual/en/zend.loader.autoloader-resource.html#zend.loader.autoloader-resource.module for info on the Resource / Module autoloader.

You could do things the old fashioned way though and just require_once('BaseController.php');

smack0007
I will stick to require_once since I need it only 1 time. But will keep in mind, that to have any custom files I must created custom autoloader class. Thanks!
PHP thinker