I created a new application using Yii2 and added a new theme:
Created a directory in /var/www/html/<project_name>/web/themes/<theme_name>
Then create a subdirectory and related files.
<theme_name>
-layouts
main.php
-css
style.css
-js
scrippt.js
-images
logo.jpg
After that my topic in config/web.php
$config = [
..........
'components' => [
'view' => [
'theme' => [
'pathMap' => ['@app/views' => '@app/themes/<theme_name>'],
]
],
...........
]
];
Then i changed assets/AppAsset.php
class AppAsset extends AssetBundle
{
public $sourcePath = '@app/themes/<theme_name>';
public $css = [
'css/style.css'
];
public $js = [
'js/scrippt.js',
];
public $depends = [
];
}
In main.php:
<img src="/images/logo.jpg" alt="">
Error: logo.jpg not found.
Where is my mistake?
user4399689
source
share