Yii Framework Forum: Yii2 advanced app template usage - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii2 advanced app template usage

#1 User is offline   mathiasa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 24-June 14

Posted 24 October 2016 - 12:53 PM

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?
0

#2 User is offline   mathiasa 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 24-June 14

Posted 24 October 2016 - 01:00 PM

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

Could I have specified this already with Gii?
0

#3 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,184
  • Joined: 17-January 09
  • Location:Russia

Posted 24 October 2016 - 01:12 PM

Yes, you're able to specify namespace for Gii.
Yii 2.0 Development Cookbook

Enjoying Yii? Star us at github

Support me so I can work more on Yii: https://www.patreon.com/samdark
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users