在Windows上更少使用symfony2 [英] using less with symfony2 on windows

查看:76
本文介绍了在Windows上更少使用symfony2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows OS上进行开发时,我试图通过精打细算来减少工作量.

我正在加载一个现有项目,我可以根据需要更改config.yml和parameters.yml文件.

到目前为止的步骤:

  1. 我已经通过msi安装程序安装了Node.js
  2. 我已经使用过npm并且安装得没有那么麻烦

config.yml

assetic:
      debug:          %kernel.debug%
      use_controller: false
      bundles:        [ FOSUserBundle ]
      filters:
          less:
              node: "C:\\Program Files (x86)\\nodejs\\node.exe" #/usr/local/bin/node
              node_paths: [C:\Users\matt\AppData\Roaming\npm\node_modules\less] #[ /usr/local/lib/node_modules ]
              apply_to: "\.less$"

我曾尝试将appdata/roaming/npm/node_modules/less目录直接移到program files (x86)/nodejs/node_modules目录中的本地node_modules目录中,但无济于事.

我还尝试设置将roaming/npm/node_modules/less dir添加到环境路径中,没有任何乐趣.

我曾尝试将less直接安装到项目中,并直接将node_path指向项目,

输出的css文件中的错误如下:

[例外] 500 |内部服务器错误| Assetic \ Exception \ FilterException [消息]运行时发生错误: "C:\ Program Files(x86)\ nodejs \ node.exe" "C:\ Users \ Matt \ AppData \ Local \ Temp \ assEC1E.tmp"

(这无济于事)

任何帮助表示赞赏,我们都被困在办公室了.

解决方案

这是一个古老的问题,但是,由于我发现了同样的问题,并且最终解决了这一问题,所以我想发布答案.

在Windows上使用LESS的推荐方法是使用lessphp软件包.要添加它,您只需在composer json中添加以下行:

"require": {
    .....
    "leafo/lessphp": "dev-master",
    .....
}

然后您必须运行

$ php composer.phar update

并使用以下配置更新您的app/config/config.yml:

assetic:
    #...
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"

完成此操作后,您将可以预处理LESS文件并生成CSS文件.

然后,当您要处理资产文件时,只需在视图中包括该过滤器,例如:

{% stylesheets filter='lessphp' output='css/main.css'
    '@AppBundle/Resources/public/less/*'
%}

Im trying to get Less with assetic working while developing on a windows OS.

Im loading an existing project of which I can alter the config.yml and parameters.yml files as necessary.

steps so far:

  1. I have installed Node.js via the msi installer
  2. I have used npm and installed less gloabally

config.yml

assetic:
      debug:          %kernel.debug%
      use_controller: false
      bundles:        [ FOSUserBundle ]
      filters:
          less:
              node: "C:\\Program Files (x86)\\nodejs\\node.exe" #/usr/local/bin/node
              node_paths: [C:\Users\matt\AppData\Roaming\npm\node_modules\less] #[ /usr/local/lib/node_modules ]
              apply_to: "\.less$"

Ive tried moving the appdata/roaming/npm/node_modules/less dir straight into the local node_modules dir in program files (x86)/nodejs/node_modules dir to no avail.

Ive also tried setting adding the roaming/npm/node_modules/less dir to the environment path, no joy.

Ive tried installing less directly into the project and pointing the node_path directly to it, no joy.

the error in the outputted css file is as below:

[exception] 500 | Internal Server Error | Assetic\Exception\FilterException [message] An error occurred while running: "C:\Program Files (x86)\nodejs\node.exe" "C:\Users\Matt\AppData\Local\Temp\assEC1E.tmp"

(which is rather unhelpful)

any help appreciated, we're all a bit stuck in the office.

解决方案

This is an old question but, as I've found the same problem and I finally solved it, I wanted to post the answer.

The recommended way to use LESS on Windows is to use lessphp package. To add it you just add in your composer json the following line:

"require": {
    .....
    "leafo/lessphp": "dev-master",
    .....
}

Then you must run

$ php composer.phar update

and update your app/config/config.yml with this configuration:

assetic:
    #...
    filters:
        lessphp:
            file: %kernel.root_dir%/../vendor/leafo/lessphp/lessc.inc.php
            apply_to: "\.less$"

Once you have do this, you will be able to preprocess the LESS files and generate the CSS files.

Then when you want to process the files with assetic you just have to include that filter in your views like, for example:

{% stylesheets filter='lessphp' output='css/main.css'
    '@AppBundle/Resources/public/less/*'
%}

这篇关于在Windows上更少使用symfony2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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