[英]Symfony 3.4 the folder where web assets is set
In symfony 2.*在 symfony 2.*
I put /images
or /js
under each bundle Resources
folder, then我将/images
或/js
放在每个包Resources
文件夹下,然后
php bin/console assets:install web
it deploys the js and images to web/public
它将 js 和图像部署到web/public
Now in Symfony 3.4现在在 Symfony 3.4
All *.html.twig
files are under /app/Resources/view
folder.所有*.html.twig
文件都在/app/Resources/view
文件夹下。
So,I put assets files next to it like /app/Resource/public/js
/app/Resource/public/images
and so on.所以,我把资产文件放在它旁边,比如/app/Resource/public/js
/app/Resource/public/images
等等。
Is it correct??这是正确的吗?? and how can I deploy these files to web
directly??以及如何将这些文件直接部署到web
?
related article is here相关文章在这里
I have read this page but can't find the answer.我已阅读此页面,但找不到答案。
You can simply put them in the public
directory.您可以简单地将它们放在public
目录中。
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. Symfony 4 中不再存在项目包。此外,您不再需要使用使用新结构的assets:install
命令。
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).我知道您使用的是 Symfony 3.4(这是旧的 lts 版本)。
As stated in your article :如您的文章所述:
Store your assets in the web/ directory.将您的资产存储在 web/ 目录中。
which is different with the version 4.0, where the assets would go to the /public
directory.这与 4.0 版本不同,其中资产将转到/public
目录。
When you put your assets in the /web
directory, you can of course access them with the {{ asset()}}
function.当您将资产放在/web
目录中时,您当然可以使用{{ asset()}}
函数访问它们。 (for instance {{ asset('img/my-picture.jpg') }}
) (例如{{ asset('img/my-picture.jpg') }}
)
Hope it helped.希望它有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.