Yii2 advanced app template usage

I’m making a squash platform, where tournament organizers can register events which players can enter.

I’ve made an advanced template app using yii2 and migrations. I used gii to create models and crud. Gii automatically generated the models in the backend/models directory and I also created controllers and views for the backend. Most of the models I use in the back as well as in the frontend, so I need a way to access those models from the frontend.

I tried to load a player view in the front-end. For this I created a PlayerController and a view in the front-end. When I try to access it in the browser I get:

Class ‘app\models\Spieler’ not found

I tried moving all the models from backend/models to common/models, but then I can’t access the models from either front- or backend. The model classes still have namespace app\models.

How can I access these classes that I put in common/models the from back- or front?

Ah, I think I have to change to namespace from app\models to common\models

Could I have specified this already with Gii?

Yes, you’re able to specify namespace for Gii.