samdark / yii2-cookbook

Yii 2.0 Community Cookbook
1.45k stars 296 forks source link

Structure: backend and frontend via modules (Suggestion) #46

Open albaraam opened 9 years ago

albaraam commented 9 years ago

It was great Idea, but I have one issue while applying it. Now with what we have, I can open blogFrontend or blogBackend regardless of the current running application. So it would be great if you can mention some way to automate this routing between backend and frontend. I would like to know what do you think? how can I restrict this? (See the following links).

http://example.com/frontend/blog/   == will take you to ==> blog-frontend
http://example.com/backend/blog/  == will take you to ==> blog-backend

Note: I'm not talking about pretty urls, I'm talking about current running application.

samdark commented 9 years ago

If frontend and backend are modules, it's the same application.

albaraam commented 9 years ago

Ah, okay! did you mean that this way could be used instead of the advanced template architecture?

Advanced Template Architecture  ==>  2 different applications (frontend & backend)
Backend & Frontend via modules ==> 1 application with packages consist of frontend & backend modules

or could they work in conjunction together?

Advanced Template Architecture:
    backend => application for statistics and such things
    frontend => packages consist of frontend & backend modules
samdark commented 9 years ago

Both are possible. Yii doesn't limit the way you structure your application.

albaraam commented 9 years ago

I know that all what I mentioned is possible in Yii, I just want to know what is your point of view? what do you think? which one is a cleaner architecture? how would you approach complex applications?

samdark commented 9 years ago

It depends on the application. Usually I'm following advanced project template i.e. application per tier. It allows you to deploy to multiple servers/domain easily.

albaraam commented 9 years ago

Okay, I'll just give the following scenario to discuss. Lets say we have a project that consist of many sections, and one of them is a blog. Then, where would you put "Content Creating" part (Admin)? Blog representation ?

would you put them both in frontend application? then what could backend application used for?

I think just the terminology we are using here is what makes me confused a little bit. Since we are usually refer to frontend to some thing related to endusers (representation) and not administrative tasks like content creating and editing.

I hope you can help me understand this better.

samdark commented 9 years ago

Depends on how the blog is managed. If it's admin-managed one i.e. users are reading it and never writing to it, I'll use admin app for it. If it's multi-user blog users can post to then I'd choose to have management stuff right in the main application.

albaraam commented 9 years ago

Great :+1: that was much clearer, specially naming them "admin app" & "main app" I think I got the answer to my question, thanks a lot @samdark