0

I am in process of planning web application by following the best practices and approaches of software development. I am building this application using zend framework 2 and going through its documentation and best practices of building applications through zend framework 2 and MVC patterns.

Right now I am confused about where to keep my model layers. So far all the applications I have developed using Zend I used to keep my model layers in application module because I think models are not related to single module and a single module may communicate with multiple models. Also in Zf2 modules gets loaded only when it is requested except the Application module which loads with every request despite which module is requested. If I place my models in the specific modules and load them in the service config of there relative modules. I will not be able to use them in other modules.

So what should I do?

asked Aug 2, 2013 at 21:41
1
  • all modules are loaded for every request. If you couldn't use something, you might have tried using it before loading process complete. There's an event you can listen to to know when modules are ready. Also, more modules means more loading time. Commented Nov 17, 2013 at 23:10

1 Answer 1

1

You should not get worry about how the models will load. Zend Framework 2 is 'engineered' in modular way, what I want to say here is that it uses the famous design patterns (factory, dependency injection, service locater) and architecutral patterns to do the things. Remember, each module 'must be' cohesive in itself. And not coupled with any other module. Like the application module and your-other-module must implement their own models respectively to interact with the database. And in future if you replace your-other-module with some another-amazing-module, no other module would be disturbed.

At the end app runs, it integrates all the configurations in each module in one configuration and thus it works. Yes, it integrates all the end, but the framework is made to be modular and maintainable for long-lasting and separated chunks. You may use the chunks in your app or use whole MVC stack.

Thats why also a developer of Yii and CI, i feel Zend Framework 2 is most less forcing developers to use something and giving you so many choices. It may not be quick to develop apps in it but it is very flexible and a master piece.

answered Nov 17, 2013 at 16:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.