1

Coming from ZendFramework 1 to ZendFramework 2 I'm a bit confused as to the functionality of the modules. In ZF1 a module was a sub-application, so you'd have a 'default' module and maybe an 'admin' module that would handle the administration section of the system and there'd be models, views, and controllers underneath each of those modules.

It seems that in ZF2 a module is more fine-grained? In the tutorial project they created an "Album" module which seems like it is only configured for a single controller. What if you wanted to maintain users and they each had a bunch of albums? Would you create another module for 'Users' with it's own controllers/views/models, or would you create a 'UserController' inside of the 'Album' module?

What if you wanted to provide an api endpoint into those controllers? Is that yet more modules, or do you provide a route in the album controller pointing to '/api/album' which specifies a rest style controller?

1

1 Answer 1

1

Zend 2 takes a modular approach to everything. It is really up to you how fine grained you want your modules to be. If album and user are decoupled and could be reusable then it makes sense to have them in separate modules. Since an album may not ALWAYS have users and vice versa. However if you write the code in such a way that user and album are tightly coupled they might as well be in the same module. zf2 is very flexible and this is really a design decision you need to make

With regard to your API question I would say you would have the Rest controller and the controller in the same modulle and use the module config routing as you say

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.