Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

First of all, not all parts of the Zend Framework enforce the class naming convention, at least not upon calling ‘em. For example, view helpers are called directly by the ‘chopped’ class name:

// actual class name:
class Path_To_The_CustomViewHelper {}

// calling it in the view:
$this->CustomViewhelper();

Also, models are both named, and called by their class names without any paths (but yes we have to include them in the include paths).

You would think that in most cases calling the classes by their full names (with paths) should work, right?

Wrong.

  • Digg
  • DZone
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter

Related posts

Tags: , ,

Comments Section

4 Responses to “”

Sidebar might be covered by comments ... consider it a feature! ;)
  1. 1

    Zend_Loader always expects class names to match paths, this is how it knows where to find them. Helpers and Controller classes are special cases, are used internally and shouldn’t ever need to be loaded by Zend_Loader, which is why they have different naming conventions.

    The only situation I can think of in which this would be an issue would be if you were trying to get one of your controllers to extend some base class that wasn’t yet loaded. Zend_Loader would then try and find the class based on the name. Is this what you’re trying to do?

  2. 2

    I agree that the naming conventions/requirements can be somewhat confusing, but it does seem like a good balance between representing the MVC architecture in the default directory structures and having a standard naming convention.

  3. 3

    It’s really rare to need to load a controller manually as any common functionality between controllers should be factored out in action helpers.

    Regards,

    Rob…

  4. 4

    I have to agree with the fact that it makes life harder…
    they don’t follow their own convention!
    I have tried to have a simple solution to have a controller inheriting from another one (e.g. testController extends indexController )… it can be done, but it cannot be loaded just by the autoloader … so it needs a stupid fix!
    too bad ;-)