Answer the question
In order to leave comments, you need to log in
YII2 How to create a flexible modular architecture?
Hello! I am developing a project in YII2 and I need your help in understanding the architecture of modules and routing.
There is a Yii2-Advanced application. In it, I would like to implement a modular structure so that it would be possible to cut down and expand the functionality (in fact, everyone wants this). You need to make a website with a bunch of pages of the same type and pages on which additional functionality will be placed.
Let's say we have a Pages module that is responsible for working with all pages on the site. It forms a tree of pages and their URLs (depending on the nesting and alias that the admin came up with), and connects templates and content to them. And let's say in the admin panel we create the following page structure:
In parseRequest:
- Looking for /city/events/most-popular. Not found.
- Looking for /city/events. Found. Type "news". We start recursion:
$r = clone $request;
$r->setPathInfo('news/most-popular');
return $manager->parseRequest($r);
Answer the question
In order to leave comments, you need to log in
In my opinion, you have not quite correctly divided your system into modules: Home, About the company, Contacts - these are ordinary pages of the site there are no questions, but news is not just pages - this is a separate module that can have its own specific functionality - search, tags, likes and etc. Accordingly, I would recommend that you divide this task into two modules:
1. Static content module - which will contain information pages of the site, such as "about the company", "contacts", etc.
2. News module - containing actually all the news
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question