Php 包括不属于';t成捆
我正在尝试使用Assetic来包含我的基础css和js资产,这些资产不在捆绑包中。它们位于Php 包括不属于';t成捆,php,symfony,Php,Symfony,我正在尝试使用Assetic来包含我的基础css和js资产,这些资产不在捆绑包中。它们位于MySymfonyApp/app/Resources/public/css/和MySymfonyApp/app/Resources/public/js/中 {% stylesheets '@css_boostrap' %} <link href="{{ asset_url }}" type="text/css" rel="stylesheet" /> {% endstylesheets
MySymfonyApp/app/Resources/public/css/
和MySymfonyApp/app/Resources/public/js/
中
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
我的base.html.twig
模板中有以下内容,但我得到了404
{% stylesheets '%kernel.root_dir%/Resources/public/css/*' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{% javascripts
'%kernel.root_dir%/Resources/public/js/jQuery.js'
'%kernel.root_dir%/Resources/public/js/*' %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{%stylesheets'%kernel.root\u dir%/Resources/public/css/*'%}
{%endstylesheets%}
{%javascripts
“%kernel.root\u dir%/Resources/public/js/jQuery.js”
“%kernel.root\u dir%/Resources/public/js/*”%}
{%endjavascripts%}
我也尝试过以下方法,但效果相同
{% stylesheets '../app/Resources/public/css/*' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{%stylesheets'../app/Resources/public/css/*'%}
{%endstylesheets%}
如何引用不在捆绑包中的资产 解决方案:
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
app/Resources/public/*
中的资产是一个特例。它们很容易管理
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
如果您调用console命令,这些将被复制(或符号链接)到web/public/*
:
app/console assets:install web
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
。。。或者
app/console assets:install web --symlink
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
现在可以直接从web
-文件夹中包含这些资产
<script src="{{ asset('js/jquery.js') }}"></script>
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
现在执行控制台命令
app/console assetic:dump
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
。。。并将其包含在您的一个模板中:
{% stylesheets '@css_boostrap' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{%stylesheets'@css\u boostrap%}
{%endstylesheets%}