Danny Valariola
Danny Valariola

Reputation: 1118

Yii2 sharing namespaces between view and controller

I have my application controllers configured with namespace as following:

 use yii\helpers\Html;

When i try to access the Html class within the view: I get an exception, and have to re-declare the use statement.

Can i share the controller / view namespace?

Upvotes: 0

Views: 238

Answers (1)

aslawin
aslawin

Reputation: 1981

Controllers and views are differrent parts of your application. So you should declare uses in both controllers and views. This is not a bug, it's a common practice.

Upvotes: 1

Related Questions