Windows上的symfony2 assetics yui压缩程序(路径语法) [英] symfony2 assetics yui compressor on windows (path syntax)

查看:110
本文介绍了Windows上的symfony2 assetics yui压缩程序(路径语法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让资产管理器和yui压缩器一起运行,如果正在运行,请使用sass.现在,两者都不起作用.从config.yml和树枝模板中删除所有过滤器时,它会起作用,并且php app/console assetic:dump确实会复制css和js文件.

I'm trying to get assetics running with the yui compressor and, if this is running, sass. Right now, both don't work. When removing all filters from config.yml and the twig template, it works and php app/console assetic:dump does copy the css and js files.

现在,我想添加yui压缩器,我的config.yml如下所示:

Now I want to add the yui compressor and my config.yml looks like this:

assetic:
  debug: %kernel.debug%
  use_controller: false
  filters:
    yui_js:
      jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.6.jar

将过滤器添加到模板并再次运行assetic:dump会导致以下错误(由我翻译消息):

Adding the filter to the template and running assetic:dump again ends in the following error (translation of message by me):

[RuntimeException]
The syntax for filename, directory name or drive name is wrong

我发现了一篇文章告诉我指定java.exe的路径,所以我将其添加到config.yml:

I found an article telling me to specify the path to java.exe, so I add this to config.yml:

assetic:
  ..
  java: C:/Program Files (x86)/Java/jre6/bin/java.exe
  ..

现在资产:转储告诉我:

Now assetic:dump tells me:

[RuntimeException]
The COMMAND "C:/Program" is either written wrong or

我尝试在配置中使用两个变量(使用\或\而不是/,添加单引号或双引号,使用短别名Progra〜1或Progra〜2),但是我什么也没得到.两种错误一直存在.也许有人可以指出我正确的方向.

I tried playing around with both variables (using \ or \ instead of /, adding single or double quotes, working with short alias Progra~1 or Progra~2) in the config, but I didn't get anywhere. The both errors comming up all the time. Maybe someone can point me in the right direction.

推荐答案

好,我知道了.伙计,这是残酷的.

Ok, I figured it out. Man, this one was brutal.

让我们从简单的东西开始. config.yml的工作版本如下所示:

Let's start with the easy stuff. A working version of the config.yml can look like this:

assetic:
  debug: false
  use_controller: false
  java: C:\Program Files (x86)\Java\jre6\bin\java.exe
  sass: C:\Program Files (x86)\Ruby192\bin\sass.bat
  filters:
    scss: ~
    yui_js:
      jar: %kernel.root_dir%\Resources\java\yuicompressor-2.4.6.jar

由于某种原因,资产管理系统始终会为scss导入整个目录,因此我必须制作一个Combine.scss,以正确的顺序导入其他scss文件.

For some reason, assetic is always importing a whole directory for scss, so I had to make a combine.scss which imports the other scss files in the correct order.

现在变得很丑陋,因为必须更改资产核心以使其正常工作. Assetic的开发人员知道此错误,我认为它已在某些开发主干/分支中得到了解决,但在稳定的分支中却未得到解决.

And now it gets ugly, as one have to change the assetics core in order to get this working. The developers of assetic know this bug and I think it is fixed in some development trunk/branch but not the stable one.

必须在第95行上更改 Assetic \ Util \ ProcessBuilder

The Assetic\Util\ProcessBuilder has to be changed on line 95

if (defined('PHP_WINDOWS_VERSION_MAJOR')) {

,第103行

$script .= ' '.implode(' ', array_map('escapeshellarg', $args));

和第110行

return new Process($script, $this->cwd, null, $this->stdin, $this->timeout, $options);

我希望这个错误能尽快得到解决,直到有人尝试使其正常工作才发现该线程...就像我花了8个小时进行调试,阅读和尝试不同的方法一样.

I hope this bug get fixed soon and till then anybody trying to get it working finds this thread... Took me like 8 hours of debuging, reading and trying different approaches.

这篇关于Windows上的symfony2 assetics yui压缩程序(路径语法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆