In symfony 2.*
I put /images
or /js
under each bundle Resources
folder, then
php bin/console assets:install web
it deploys the js and images to web/public
Now in Symfony 3.4
All *.html.twig
files are under /app/Resources/view
folder.
So,I put assets files next to it like /app/Resource/public/js
/app/Resource/public/images
and so on.
Is it correct?? and how can I deploy these files to web
directly??
related article is here
I have read this page but can't find the answer.
You can simply put them in the public
directory.
The project-bundles no longer exist in the Symfony 4. Also you are no longer required to use the assets:install
command using the new structure.
For example :
public/
img/
header.jpg
You can then reference this asset using the asset twig function as follows:
{{ asset('img/header.jpg') }}
I understand that you are using Symfony 3.4 (which is the old lts version).
As stated in your article :
Store your assets in the web/ directory.
which is different with the version 4.0, where the assets would go to the /public
directory.
When you put your assets in the /web
directory, you can of course access them with the {{ asset()}}
function. (for instance {{ asset('img/my-picture.jpg') }}
)
Hope it helped.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.