Zend Framework 2 architecture and model consulting

I would like to start working with Zend Framework 2 and need some guidance regarding the architecture of the framework. I compared the Akrabat ZF2 tutorial with it the equivalent of ZF1 and the main difference that I have noticed so far seems to be using modules . I like the idea of ​​modules as independent and reusable code snippets, and I think this could help segment your application and make it more convenient. For example, I could have the following mapping URL => module :

 http://example.org/products => Products module http://example.org/services => Services module http://example.org/oauth => Oauth module [...] 

What I'm confused about, some of my modules will use the same basic database resources (for example, both Products and Services use the same table for comments) and, therefore, the same database models. Accordingly, I am wondering:

Where should I put my database models when they are used by several modules?

+4
source share
1 answer

See the following article: http://adam.lundrigan.ca/2011/09/module-dependencies-in-zf2/

You can create a third module (example: Base, Main), which is a dependency for modules of products and services, or you can add Models to one of your modules and use this module as a dependency for another.

module.php

 /** * Get dependencies * * @return array */ public function getDependencies() { return array( 'BaseModule' => array( 'version' => '>=0.1.0', 'required' => true ), ); } 
+3
source

Source: https://habr.com/ru/post/1414846/


All Articles