Advanced template user crud advice and addtional tables


Im new to Yii but not new to php frameworks in general. I really like the look of yii 2.0 but not sure of the best way to go about things yet.

I have downloaded the advanced template to experiment with and got it up and running without any problems. Now I see the application is split up into frontend, backend and common which makes perfect sense but Im confused about how to add crud in the backend for users which sits in the common folder. Do I use Gii to create all new model, controller and view for users in the backend application? If not how do I add crud that will be under the backend login but use the common user model?

Also my experimental project is a workout routine app which will have a database schema similar to this:

Edit: Dam cant insert links I have attached the image instead

I think most of the main tables will be shared between the front and backend of the site but I will need crud access in the back. How would I go about using Gii to create this structure and maintain all the relationship join tables ect so that it will all work via active records without having to worry about the join tables in querys. Obviously person will be changed to user etc.

Does this make sense?

It is all in namespaces.

If you have UserController in backend that should use User model in common, then just at the top of UserController "use" User model from common like this:

use common\models\User;

Yii will autoload User model properly because User model is namespaced with "common\models".

You can try my improved advanced template, it already has this implemented, so you can use it to learn.

Update: when using gii, you will have to adjust namespaces that will be used for your generated code.

Ok that makes sense. What about my second question about using GII to automatically build the crud for that data in the picture?

Gii will create relations for you in your models, maybe you will have to customize them a bit, but most of the work will be done by Gii. It doesn’t matter where you will put those models, as long as you namespace them and use them right. As I said previously, you will have to customize namespaces when creating models and crud with gii.

Ok I guess I am just going to have to play with it some more. One last thing my front end application is going to be a mobile app so I want to replace bootstrap 3 with jquery mobile on the front end only and keep bootstrap for the back end. Will I be able to set it up in composer like this or will I have to manually strip out the front template an replace it with Jquery mobile.

Just trying to figure out how to save as much time as possible when setting up projects as that why I want to start using Yii.