Handling User Module On Both Frontend And Backend


I’m writing this message because I’m a bit lost:

I’m developing an application with a frontend and a backend. I have adopted an architecture separating my workspace between frontend, backend and common folders (similar to the YiiBoilerPlate architecture).

Now I want some User features (login, etc) on both backend and frontend, but obviously separated modules since backend users and frontend users aren’t the same. I adapted the yii-user module to my architecture, and it works like a charm.

Now the tricky part. Actually the frontend users and the backend users are not totally independent, meaning, the Backend User table and the Frontend User table are somehow related via relations in Active Record Model. Then I have absolutely no idea on how to make everything work together.

Here are some of the options I thought about:

1/ I can rename one module/use namespace, to avoid name conflicts, but then I have to load, for example, the frontend user module into my backend application, when all I care about is a couple of Active Record Model for my relations.

2/ I can put both modules into my common/modules folder (and obviously rename one so they are not the same), but then I guess that even on my backend I could have access to the controller/view of the frontend user module. Which I don’t want.

3/ I could make some annoying ajustments, like put my active record models in my common/models folder, so that all the models are always autoloaded, both on backend and frontend. And put the rest in backend or frontend modules folder. But then, I have to rewrite the models since they use classes that are defined in the module (like UserModule, to begin with). And this is basically losing all the advantage of using a model.

I really don’t know. How people handle it? When you have a backend and frontend User features and that somehow the two of them are not totally decorellated …

I’m getting crazy … Thanks a lot for your help.

Anyone ?

Have you revisited this assumption? Are they stored in the same or separate DB table?

They are stored in the same DB.

Actually it could be possible to store them in the same table but it would be a little awkward :

My website is listing holidays

Backend user are holidays providers

Frontend users are members who want to book holidays.

Hence, the two tables are pretty much different with different profile fields, but I guess I can then have 2 Profiles tables. Maybe that could be the idea, I’ll try to figure out what I can do.

Do you have any experience proceeding like that ?


It seems to me that having backend and frontend Users with two different Profiles should be pretty much standard for a lot of website.

Nevertheless I can’t seem to find any answer on the net and this topic stay desperately inactive.

Is there something I missed, am I doing something wrong ?