Need the difference between frontend,common & backend modules?

Hi, i am new to yii2 ,

can some one explain me what is exact difference between frontend,backend and common modules.

how they differ?

Thank you :rolleyes:

The way I see it is

frontend - is your website/application that the public will view

common - is for things that the backend and frontend share such as models

backend - isn’t essential however it could for example be used for CMS so backend is like wordpress admin if you were to build a CMS

Here explains everything in more detail:

Yii2 Documentation

hi thanks for the answer,

but i still didn’t get it, i have created some Mvc’s in backend and also in frontend. And i can access both the controlles from browser :huh: , how exactly they differ ?

1 Like

They don’t differ…

How much they differ depends on how much you make them different. ;)

Lets say you want to code some kind of blog system…

With Articles, Categories, Comments etc etc.

Frontend users should only be able to write comments.

Backend users should be able to create, edit, delete articles and categories… and should be allowed to approve comments.

Now you can seperate the "Admin-Code" from the "User-code".


In Frontend you only write code to display your blog and to write comments.

In Backend you would build the code to create / manage the blog and comments…

This is all a CAN no MUST.

You can also write everything in frontend or only in backend…

But that would make advanced templates pretty much like the basic one. :)

Hope it is more clear?


In my understanding, they are just how we organize things. Some applications don’t need to separate between front end and back end. You can just put everything as one module (like basic template). Then, you can limit the user access and layout by defining roles.

At first, I am also confused about the front end and back end separation. Why do you need to split your app while you can just use roles to limit the access and build the layout?

But, then look at the CMS, like Joomla/typo3/wordpress. They organize the apps into front end and back end. We can say this is for security reason or to give better and organized arrangement. Front end is used to display all the content while back end is used to manage the content, prepare the content to be publish next month or archiving published contents.

At the moment, I am upgrading my shop application from yii 1 into yii 2. I tried to use advanced template. The core of this app is the item model, where all items are stored. Information such as barcode, name, description, photo, baseUnit and status are stored here. Since I will use item in my application front end or back end, I put the item model in common folder. The front end is where the sales process is happening. Hence, I also create the SalesItem.php and put it into the front end folder. SalesItem is differ from Item by having salesPrice and salesUnit in addition to the attributes in Item. I will use SalesItem in SalesDetail table. While in the back end, I could have StockItem and PurchaseItem. StockItem is differ from SalesItem and Item since they also calculate the current stock level. PurchaseItem will differ by having purchase price inside it.

As the summary, this is just how we organize things. There is no limit that we can use front end model in back end controller since we can access them using namespaces. Also I think we can use the same name, say Item in common, front end and back end.

Please give feedback if there is mistake in my unerstanding.

[font=“Microsoft Sans Serif”]Thank you MetaCrawler,Daniel and con322 :)

I got clear idea on these things , thank you very much guyzz :D