简体   繁体   中英

Do I need to separate models, views and controllers for back-end and front-end?

I'm developing MVC engine for real estate web-site from scratch.

Currently I have this folder structure:

/app
    /frontend
        /controller
        /model
        /view
    /backend
        /controller
        /model
        /view
    /common
        /controller
        /model
        /view
/lib
/log

index.php
backend.php
config.php
bootstrap.php
.htaccess

It is good idea to separate MVC classes for public and admin website such way? Or it is better to make one folder for all MVC classes and set privilegies for actions like create, update, delete? Which is more secure?

Thank you.

I did something similar recently that included a public and an administrative area. I investigated common controllers with access controls but soon realized they were better off kept separately.

Your application logic will differ in the administrative section, and so will your templates. The only thing similar will be your models so those can be shared to avoid duplication of data. What you can do is extend your models for your administrative section in case you want to add admin-specific functionality to them.

Probably the former. However - I think it is not needed to split into 3 parts. Just two - common and admin. Because the admin will just use common functions and adds some for writing, while common are just functions for reading.

我实际上会在具有适当权限的情况下继续使用后者。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM