0

I understand building a module is like a mini Yii2 application. I am trying to build a Blog module to reuse on different projects.

I would like to create a module containing backend and frontend and then being able to access each side.

In Yii2 basic there is no backend and frontend, so I create the "modules" folder on the app root. In the case of Yii2 advanced since we have backend and frontend.

All tutorials only show creating a module for backend or frontend.

I am creating a folder "modules" inside common. Inside module I am creating a folder "blog" with the following structure:

blog
L backend
L frontend
L common

what is the correct way to create and configure a module?

UPDATE I have found this article from @samdark, where He gives an example of the configuration, I am showing the configuration according to my structure:

'modules' => [
  'blogFrontend' => [
    'class' => 'common\blog\frontend\Blog',
    'anonymousComments' => false,
  ],
  'blogBackend' => [
    'class' => 'common\blog\backend\Blog',
  ],
]
Eduardo
  • 1,781
  • 3
  • 26
  • 61
  • Yes if you have to create the module for backend and frontend that is the preferred way to do to place it in the `common` folder and create directory structure relative to the `frontend` and `backend`. – Muhammad Omer Aslam Jan 15 '18 at 00:22
  • if you plan to reuse your modules in other projects, place your modules in a custom extension. try gii, then read http://www.yiiframework.com/wiki/846/yii2-how-to-create-develop-a-new-extension-using-composer-locally-without-version-control-or-git/ – e-frank Jan 17 '18 at 15:43
  • @MuhammadOmerAslam, thanks for the feedback – Eduardo Jan 23 '18 at 01:44
  • @e-frank Really interesting article, I will review it. – Eduardo Jan 23 '18 at 01:44

0 Answers0