所以,有一个问题:我尝试在Windows机器上通过symfony2构建资产转储:
php app/console assetic:dump
然后我得到以下内容:
[dir+] D:/Projects/domain/app/../web/js/compiled
[file+] D:/Projects/domain/app/../web/js/compiled/main.js
[Assetic\Exception\FilterException]
An error occurred while running:
"C:\Program Files\Java\jre7\bin\java.exe" "-jar" "D:/Projects/domain/app/Resources/java/yuicompressor-2.4.8.jar" "--charset" "UTF-8" "-o" "C:\Users\username\AppData\Local\Temp\YUIF039.tmp" "--type" "js" "C:\Users\username\AppData\Local\Temp\YUIF038.tmp"
Error Output:
java.io.FileNotFoundException: UsersusernameAppDataLocalTempYUIF039.tmp:\Users\username\AppData\Local\Temp\YUIF038.tmp (the filename,directory name, or volume label syntax is incorrect)
Input:
var a = 1;
alert (a);
创建文件夹“web / js / compiled”但保持为空。 我可以“实时”看到YUIF03 * .tmp文件是如何在我的TEMP文件夹中的此操作中创建和删除的。 这个问题发生在我试过的两台Windows机器上,但我在Linux虚拟机上没有这个问题。 似乎文件路径不正确存在问题
UsersusernameAppDataLocalTempYUIF039.tmp:\Users\username\AppData\Local\Temp\YUIF038.tmp
但我不知道问题的根源(Java?YUICompressor?Symfony2?Assetic?)
以下是我的symfony2的一些配置。 composer.json:
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": ">=2.2.3,<2.4-dev",
"doctrine/doctrine-bundle": "1.2.*",
"twig/extensions": "1.0.*",
"symfony/assetic-bundle": "2.3.*",
"symfony/swiftmailer-bundle": "2.3.*",
"symfony/monolog-bundle": "2.3.*",
"sensio/distribution-bundle": "2.3.*",
"sensio/framework-extra-bundle": "2.3.*",
"sensio/generator-bundle": "2.3.*",
"incenteev/composer-parameter-handler": "~2.0"
},
config.yml:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ AcmeWebBundle ]
java: C:\Program Files\Java\jre7\bin\java.exe
filters:
cssrewrite: ~
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar
有什么想法吗?
谢谢!
答案 0 :(得分:5)
同样,这是一个错误的2.4.8错误:https://github.com/yui/yuicompressor/issues/78
只需使用2.4.7:https://github.com/yui/yuicompressor/downloads(.jar位于“build”文件夹中)。
java: "C:/Program Files (x86)/Java/jre7/bin/java.exe"
filters:
yui_css:
# 2.4.8 fail on windows
jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
答案 1 :(得分:1)
我遇到了完全相同的问题。但是,不确定它来自何处,symfony文档指出"The YUI Compressor is going through a deprecation process."因此可能不再支持它。
我设法通过尝试不同的JRE和yuicompressor.jar版本来实现它。这是适用于我的资产配置(Win7 64位):
# Assetic config
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ MyBundle ]
java: C:\Program Files\Java\jre6\bin\java.exe
filters:
cssrewrite: ~
yui_css:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
yui_js:
jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
请注意特定的jre6路径(默认情况下,我的机器上安装的jre是jre7,我得到了错误)和2.4.7 yuicompressor版本(不适用于2.4.8)。