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
Symfony2资产指南针产品和开发环境中不同的资产url路径_Symfony_Ubuntu_Sass_Assetic - Fatal编程技术网

Symfony2资产指南针产品和开发环境中不同的资产url路径

Symfony2资产指南针产品和开发环境中不同的资产url路径,symfony,ubuntu,sass,assetic,Symfony,Ubuntu,Sass,Assetic,我尝试在Ubuntu 12.04上用compass和Assetic配置我的Symfony2项目(放弃在Windows XP上用compass和Assetic运行这个项目) 我配置了compass,当我在开发环境中启动我的项目时,它可以正常工作,尽管在prod中,我从compass过滤器到css输出文件的资源url路径错误 以下是我的config.yml资产部分: # Assetic Configuration assetic: debug: %kernel.debug% use

我尝试在Ubuntu 12.04上用compass和Assetic配置我的Symfony2项目(放弃在Windows XP上用compass和Assetic运行这个项目)

我配置了compass,当我在开发环境中启动我的项目时,它可以正常工作,尽管在prod中,我从compass过滤器到css输出文件的资源url路径错误

以下是我的config.yml资产部分:

# Assetic Configuration
assetic:
debug:          %kernel.debug%
use_controller: false
#bundles:        [ ]
#java: /usr/bin/java
filters:
    cssrewrite: ~
    sass: 
      bin: /usr/local/bin/sass
      apply_to: "\.scss$"
      #bin: C:/Ruby200/bin/sass this is for Windows not working though
    compass: 
        images_dir: %kernel.root_dir%/../web/images
        http_path:  /images
        #bin: C:/Ruby200/bin/compass.bat this is for Windows not working though
        bin: /usr/local/bin/compass
    closure:
        jar: %kernel.root_dir%/Resources/java/compiler.jar
    yui_css:
        jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
我在app/Resources/views/base.html.twig

 {% stylesheets filter="compass" "@PortalSlubnyMainBundle/Resources/public/css/settings.scss"%}
 <link rel="stylesheet" href="{{ asset_url }}" />
 {% endstylesheets %}
 <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" />
{%stylesheets filter=“compass”“@portalslubymainbundle/Resources/public/css/settings.scss”%}
{%endstylesheets%}
当我通过app_dev.php运行我的项目时,我得到了正确格式化的资产url

如下所示:/app_dev.php/css/6262784_settings_1.css

在prod环境中,我得到了错误的URL,如下所示:/css/6262784.css(404未找到错误)


我清除了prod和dev的缓存,但没有任何更改

在开发环境中,assetic默认使用控制器。所以你的产品和开发环境的url是好的


要生成资产文件,您需要运行
app/console-assetic:dump
,这些文件将在生产环境中使用。

app/console-assetic:dump--env=prod--no-debug
,用于生产环境;-)