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;

OR

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

Always obtain a link like this:

/var/www/html/yii/web/themes/mytheme/web/js/

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

try:


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

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:

/var/www/html/yii/themes/mytheme/web/views/site/index.php

a photograph that needs to be used here:

/var/www/html/yii/themes/mytheme/web/images

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

can you help my ?