How do naming conventions for controllers, actions, and views work in the Zend Framework?

The Zend Framework uses “camel-casing” for controller and action names. Controller names are specified using upper camel-case and are suffixed with the word Controller (examples: IndexController, StaticContentController, FunkyChickenController), while action names are specified using lower camel-case and suffixed with the word Action (examples: indexAction, displayPostAction, redButtonAction). For modules other than the “default” module, controller names must be additionally prefixed with the module name (examples: News_IndexController,Catalog_EntryController).

View scripts take their name from the corresponding controller and action. Typically, the view script is stored in a directory corresponding to the controller name (without the Controller suffix), in a file whose name corresponds to the action name (without the Action suffix). Therefore, the view script for the clickAction in the ExampleController would be located at /views/scripts/example/click.phtml.

Multiple words in the controller or action name are represented by hyphens or periods in the corresponding view script file path. Therefore, the view script for the displayItemAction in the ShoppingCartController would be located at


To prevent name collisions, the Zend Framework also allows the use of custom namespaces, which can be prefixed to object or class names. These namespaces can be registered with the Zend Framework autoloader, to have the corresponding definitions automatically loaded on demand, as needed.

Zend Framework – Using a Modular Directory Layout

Considering that you already try to build an application with Zend Framework you already use the default module. If you want to expand your application to use more than one modules then you have to define the default module and  use a modular directory layout. A modular directory layout enforces consistency and produces a more manageable code tree.

How to Create the Default Module

The first step is to create the $APP_DIR/application/modules/ directory, and then create a set of subdirectories within that for the default module and its controllers, models and views. The zf command line tool does not create these directories, and so it is necessary to perform this task manually. In your application’s directory under the htdocs directory, there is a directory that is named application where you have to create a directory named modules and in this directory, a directory named default.

shell> cd /usr/local/apache/htdocs/square/application

shell> mkdir modules

shell> mkdir modules/default


Next, move the existing models, controllers, and views from $APP_DIR/application/* to


shell> mv controllers modules/default/

shell> mv views modules/default/

shell> mv models modules/default/

Updating the Application Configuration File

The next step is to update the global application configuration file, located at $APP_DIR/

application/configs/application.ini, with the location of the modules directory. This tells the

Zend Framework’s routing subsystem how to resolve module-specific entities.

To perform this update, open the application configuration file in a text editor and add the

following lines to the [production] section:

resources.frontController.moduleDirectory = APPLICATION_PATH “/modules”

resources.modules = “”


*info Regardless of whether or not you organize your application into modules, remember

that you can always redirect URL requests to specific modules, controllers, and actions

through the use of custom routes.