Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Module Best Practices In Split Front/Backend App #1520
What is/will be the best approach to developing and using a single module in a separated frontend/backend app such as in the advanced app template?
I'm talking about modules that might require frontend/backend separation themselves such as a blog module where you would want to manage posts, comments etc. in the backend section and display them publicly in the frontend section, all using a single module installed via composer.
Is it best to use an admin submodule or simply 'Admin' named controllers? How best to deal with config? Am I over analyzing a non-existent issue!?
Apologies if there's an obvious answer - I'm fairly new to Yii2 but, having said that, I had similar issues with modules in Yii1 and it might be good to have a more standardized approach to this that developers can follow when creating extensions.
Some thoughts I have on the issue (just thinking aloud really) ...
For users sharing modules on Github/Yii extensions directory, should they design them for the basic app structure, advanced app structure, or is there an easy way to incorporate both that everyone can use out of the box? I know it's called the 'advanced' app for a reason but if there's a good solution to handling this for everyone then it's worth doing, right?
If you do indeed use a backend module alongside a separate frontend module to cater for the advanced app as @samdark suggested, where would common module code go best? You could choose one or the other I guess, or even a third 'common' module for the extension, but something just 'feels' wrong, untidy or overcomplicated by doing it that way. Just my personal view.
I quite like how Yupe CMS - https://github.com/yupe/yupe - uses modules for Yii 1.1, whereby they allow modules to be 'installed' and 'activated' by copying the config from each module into a
I know Yii is a framework rather than a CMS but, with the way the new app templates are going, it's very close to a CMS now - just without actual content management built in as standard. Is it worth considering a core Yii extension manager similar to what Wordpress, Drupal, Joomla and other CMS's use? I mean for simpler, non-module based components/widgets as well as full blown modules. I think it would make everyone's lives a lot easier and add yet another massive plus point for using Yii2.
Like I said, just thinking aloud so make of all that what you will.
@angelcoding all your thoughts can be marked as quetions
referenced this issue
Feb 1, 2014
Yii2 has everything for implementing such an extension in a good way.
Root namespace is the same as in any extension i.e.
'modules' => [ 'blogFrontend' => [ 'class' => 'samdark\blog\frontend\Module', 'anonymousComments' => false, ], 'blogBackend' => [ 'class' => 'samdark\blog\backend\Module', ], ]
@samdark can you correct or improve this example, i would like to see how to get simple
@Ragazzo URLs are, as always, adjusted with URL rules in your application config. No directory changes needed.
I have studied the transition of Yii1 to Yii2 for a while now and I must say that the role of Modules in Yii2 is too much neglected in the upgrading docs. Many of us out here are using modules in our Yii1 projects and their application in the advanced template is vague and doesnt seem to be documented.
Important questions to be answered:
Finally, not quite unimportant is the ambiguity in the definition of a frontend & backend environment. To me the explanations in docs / comments are unclear about:
3 scenario's that overlap:
So should users with administrative rights login through the backend? It is still unclear to me.
Many questions that I would love to see answered in the official docs.