How to extend View class

Is there any way to create own view classes extended from standard yii\web\View? I wrote classes to emphasize that I need different classes for different views, but not one common "custom" view class. So that in view php files $this will represent either the respective "custom" class or standard yii\web\View if no custom class is present.

What aspects of the View object do you want to customize?

Well, you can see what View is expected to do by looking through the API reference of yii\web\View.

(http://www.yiiframework.com/doc-2.0/yii-web-view.html)

Do you really want to customize some methods of View?

I don’t think the View object is designed to be customized for each and every page. IMO, what should be customized is not the View itself, but the view scripts, layouts, and/or themes that the View object uses to render the pages.

Thank you for reply. I mainly want to add some functions to avoid big piles of php codes mixed with html and js code. Of course I can do this in controller, but I think that view is a better place for it.

I would like to know what kind of "big piles of php codes" you have in mind.

I’m not sure, but I would rather want to consider it in the model layer.