Page 1 of 1

ZF 2 - When to use Modules

Posted: Thu Oct 11, 2012 7:05 am
by shiznatix
I just today started taking a seriously look at ZF 2. I would like to re-write this one small and fairly simple website in ZF 2 but it seams that the documentation and examples just aren't really there yet.

So, my first question deals with Modules. In ZF 1.* I made each section of the website a different module. There is the default (user side) and the admin modules. Each module had all the controllers, view, layouts, etc that was needed for that specific section. The only real thing in common between the modules was the database and main configuration, which is fine for me.

Now, ZF 2 seams to go in a different direction that I am not sure of yet. As far as I have been able to gather, 1 module in ZF 2 is just 1 page (controller) with all files needed for it. This doesn't seam so great for me though as my "companies" page is 100% different on the client side and admin side.

So, really, how should I be using Modules in ZF 2 and how should I separate the different sections (user, admin) within the code structure?

P.S. If anyone has any good tutorials on how to migrate from ZF 1 to 2 I would be very interested in those links.

Re: ZF 2 - When to use Modules

Posted: Thu Oct 11, 2012 12:46 pm
by Christopher
I think you are misunderstanding ZF2 modules. They are more like complete apps that previous modules. The Module.php file configures the module, but it can have all the same MVC files -- just reorganized a little.

Re: ZF 2 - When to use Modules

Posted: Fri Oct 12, 2012 2:29 am
by shiznatix
Christopher wrote:I think you are misunderstanding ZF2 modules. They are more like complete apps that previous modules. The Module.php file configures the module, but it can have all the same MVC files -- just reorganized a little.
So would it make sense to have 1 module for the user side and 1 module for the admin side, like I have been doing or do I still not quite get it?

Re: ZF 2 - When to use Modules

Posted: Fri Oct 12, 2012 2:02 pm
by Christopher
Yes. ZF2 modules are, for better or worse, a lot more complicated than ZF1 modules. You should be able to do the same thing you did before with ZF2. That is a fine division -- especially if you reuse the admin part on multiple sites.