How to create Theme?

How can I get a link to the file "css / js"?

The thing is that I’ve tried everything, changes in main.php, etc.

I have used these codes but it did not work.

echo $this->theme->baseUrl;


echo $this->theme->getBaseUrl(); //It always appears empty

Always obtain a link like this:


or similar incorrect.

Link that I would get this: /var/www/html/yii/themes/mytheme/web/js or /themes/mytheme/web/js

Can you help my ?

Can someone will help me?

Does Yii::app()->theme->getBaseUrl(); work?

I get error:

 PHP Fatal Error – yii\base\ErrorException

Call to undefined method Yii::app()

If i use this:

 echo Yii::$app()->theme->getBaseUrl(); 

I get this error:

PHP Notice – yii\base\ErrorException

Undefined variable: app

Or if i use this code:

echo $this->theme->getBaseUrl(); 

not receiving any results, the effect of NULL



Unfortunately, nothing still does not work, even such a solution.

<img src="<?php echo Yii::$app->assetManager->publish('@app/themes/mytheme/web/')[0] ?>/images/myimg.jpg" alt="logo">

(I also used:Yii::$app->assetManager->publish(’@app/themes/mytheme/web/’))

I have one problem, my views file is located here:


a photograph that needs to be used here:


I care about the views that files can display images, but do not know how to do it.

can you help my ?