I cant link my style in Symfony.
<link rel="stylesheet" href="{{ asset('assets/styles/css/global.min.css') }}" />
My CSS file is in assets dir
- yes i have allready downloaded asset from symfony
- yes i have tried change directories
In SF3, you should store your assets in
Store your assets in the web/ directory.
https://symfony.com/doc/3.4/best_practices/web-assets.html
In SF4, you should store your assets in
Store your assets in the assets/ directory at the root of your project.
and use Webpack Encore to compile, combine and minimize web assets.
https://symfony.com/doc/current/best_practices/web-assets.html
This is my configuration (SF3):
config_dev.yml
framework:
# Assets CDN & dev paths
# change here and in the config_prod.xml
assets:
packages:
avatar:
base_path: upload/members/pics/
app_css:
base_path: css/
app_img:
base_path: img/
....
config_prod.yml - if you want to use CDN
framework:
# Assets CDN & dev paths
# change here and in the config_prod.xml
assets:
packages:
avatar:
base_path: xx.xx.xx.xx/upload/members/pics/ (IP Address of CDN)
app_css:
base_path: xx.xx.xx.xx/css/(IP Address of CDN)
app_img:
base_path: xx.xx.xx.xx/img/ (IP Address of CDN)
....
In twig :
<a href="{{ path('homepage') }}" class="logo" style="background-image:url({{ asset('logo.svg', 'app_img') }})"></a>
{{ asset('styles/css/global.min.css') }}(where your styles dir is in public)