In Zend/MVC how do I set up the controllers and views for a sub-application or submodule?

118 views Asked by At

I have all my zend applications like this

/app/
/app/registration
/app/games

I need to create a URL for games like this

mydomain.com/games/game-1

How do I set up the controllers and views in this directory structure when its like a module or sub application?

/app/games
/app/games/configs
/app/games/controllers
/app/games/controllers/Game1Controller.php
/app/games/views
...
2

There are 2 answers

0
prodigitalson On BEST ANSWER

One way would be to use the existing module conventions:

application/
  controllers/
  views/
  configs/
  modules/
    registration/
      controllers/
      views/
      configs/

The good thing about this is that ZF is already set up to handle this to some extent by convention... If you do it another way you are going to have to modify things more.

In this layout the top level controllers, views, etc.. are the Default module, while all other modules are under the modules directory.

I would also make each game its own module. If you have common code used in all games make classes you can extend and put those in your library.

0
Marcin On

You can also use zf tool zf.sh create module yourModuleName to create the default directory structure for modules.