简体   繁体   English

如何在Symfony2中使用应用程序/资源/公共

[英]How to use app/Resources/public in Symfony2

I have got a myRandomJavascriptLibrary.js file. 我有一个myRandomJavascriptLibrary.js文件。 I want to put this file in location app/Resources/public/js/ 我想将此文件放在位置app/Resources/public/js/

But I do not know how can I access to this file in app/Resources/views/base.html.twig 但是我不知道如何在app/Resources/views/base.html.twig访问此文件

I ran command app/console assets:install web --symlink 我运行了命令app/console assets:install web --symlink

What is next? 下一步是什么?

There is no need to add you global assets in app/Resources . 无需在app/Resources添加全局资产。 They should go directly into the web folder. 他们应该直接进入web文件夹。 Command assets:install is only for bundles resources. 命令assets:install仅用于捆绑软件资源。

I think you can do, using assetic : 我认为您可以做到,使用资产:

{% javascripts '../app/Resources/public/js/myRandom.js' %}
                   <script type="text/javascript" src="{{ asset_url }}"></script>
{% endjavascripts %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM