Separate front end from back end in yii application

Hi

I have created a small website management application from the ground up in php without any framework that I would like to rewrite in yii. In its current state, www.website.com is the front facing website. To modify pages for the site, administrators can login to the url www.website.com/administrator where they can create/update/delete pages among other administrative tasks.

I am trying to figure out the best way to implement this folder structure in yii where the admin portal is a separate url. Would you create separate modules, one for the front facing website and one for the administrative portal?

I am new to this and would appreciate any suggestions/guidance.

Thanks

Modules are the way to go here.

This is how i do it and works great.

I have a MyAdminController and a MyPublicController in components.

For every module, i have a controller file(or many, depends) for frontend(usually DefaultController.php) which extends MyPublicController and a AdminController.php controller which handles the admin tasks and extends MyAdminController.

With the above configuration, you would access the admin area like moduleName/admin, which is not so nice, but with some rewrite rules in the url mananger, you can route it to admin/moduleName easily .

The MyAdminController/MyPublicController handles tasks as basic authorization of users in the admin area or settings themes for frontend/backend etc, and if you need more, you can always check/set things in modules.

Just let me know if u have any questions regarding the above, i’ll be happy to help u ;)

You can also try this: http://www.yiiframework.com/search/?q=backend&type=wiki&lang=

Another option is to create an admin module.

You can manage the access of the whole module in the AdminModule.php, forbidden the access to anyone but admin user.

Here you can create your CRUD for all part of the site.

The front end I usually leave in the root of the application (I mean, not in a module).

This depends greatly on your expected usage and your level of similarity between the two sections.

If the admin section is lightly used and rather similar to the frontend, then it makes sense to simply use an admin module, as suggested above.

However for a high load website with a very busy admin section, it might make more sense to have a completly separate Yii application. This allows for example to have two different web servers, one for back and one for front, and to have subdomains set up easier : admin.website.com. There will also be less URL rules (better performance). You can share models by putting these files in a common folder and specifiying its location in the config file.

Thanks everyone

My application has very light back end access so I will try out an admin module.