Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 包括不属于';t成捆_Php_Symfony - Fatal编程技术网

Php 包括不属于';t成捆

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

我正在尝试使用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 %}
我的
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%}