Answer the question
In order to leave comments, you need to log in
Application architecture. How to make independent modules (services)?
Now I'm rewriting the site on yii1.1 and faced the following problem: It is necessary to completely rewrite the module or make some changes. But seeing the design and what the customer wants from me, I understand that the module needs to be completely rewritten (or recreated). however, you can't just delete it either, because other modules use models from the current module.
How in the future can you do so that simply by removing the module the system does not break? move all common models to a separate folder, etc.? those. should all common components of the module be placed in one shared folder? how then to structure? please advise.
Answer the question
In order to leave comments, you need to log in
I have been looking for an answer on this issue for a very long time))
You have already been sent an article on independent modules, but this is not enough. What you need:
1. Independent MODEL layer .
This folder contains Use Case (Service), Entity itself (AR), It is desirable to have repositories for isolation from the database, and another domain layer of logic that does not depend on anything. Not from the framework, not from other modules and packages. Your task is to write the code in this part so that it can be copied to any folder, set up dependencies and make this code work even with pure PHP. If you do not plan to change the framework, then you can depend on the framework.
2. Dependencies
All module dependencies can be implemented either through Interface or through events, but events are better. And then synchronize through the application or a separate module. It is also possible via api.
3. UI (user interface)
It can be dependent on other modules. It includes: controllers, views, forms, vue.js and so on. In general, what the user interacts with.
Thus, such a system is obtained if we rely on MVC :
VC - can be dependent on other modules
M - cannot be dependent on anything other than PHP. It is also desirable to separate the database layer using the Repository. Then your package will be very much independent of even the base. And you generally will not care where you store it in user or employee.
If there is such a layer, then you can safely transfer even to the future Yii3 . However, this is difficult to do in Yii1 and Yii2 . You have to dodge and it will take more time. Since the Framework itself inserts sticks for us and we have to make crutches because of its solidity. Yii1 and Yii2 developers are not used to this approach . Usually in Yii , such an understanding is “figak, figak and in production”.
It will be convenient to build such an architecture on Symfony and the future Yii3 .
Recommended reading:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question