问题描述
我对asset:dump有长期困扰.我想使用资产"从不同的捆绑软件中获取Javascript和CSS文件(我写过),并将它们收集到模板中的开发和生产环境中.每当我想转储新文件时,assetic:dump命令都会尝试在完整的断开路径中写入.
I have a longtime problem with assetic:dump. I wanna use "assetic" to get Javascript and CSS files from different bundles (I wrote) and collect them to dev and prod environment in the templates. Everytime I wanna dump new files, the assetic:dump command try to write in a complete broken path.
app/console assetic:dump
[RuntimeException]
Unable to create directory /var/www/app/../web//var/www/app/../htdocs/css
我也尝试用以下方式写内容:(无用)
I also try writing in: (nothing works)
app/console assetic:dump web
app/console assetic:dump .
app/console assetic:dump /var/www/web
我这样配置资产:
assetic:
debug: %kernel.debug%
use_controller: false
read_from: "%kernel.root_dir%/../web"
write_to: "%kernel.root_dir%/../web"
bundles:
- MyCodeBundle
- NextCodeBundle
#java: /usr/bin/java
filters:
lessphp:
file: %kernel.root_dir%/../vendor/oyejorge/less.php/lessc.inc.php
apply_to: "\.less$"
cssrewrite: ~
我还使用 BraincraftedBootstrapBundle 在模板中使用Twitter Bootstrap Js/CSS.
I use also BraincraftedBootstrapBundle to use Twitter Bootstrap Js/CSS in my templates.
我在哪里可以修复assetic:dump的路径?
Where I can fix the path of assetic:dump?
推荐答案
如注释中所述,从web
到htdocs
的符号链接似乎存在问题.不知道这是Symfony/Assetic还是您的本地安装中的错误.
As discussed in the comments, there seems to be a problem with the symlink from web
to htdocs
. Don't know if it's a bug in Symfony/Assetic or your local installation.
但是,您甚至不需要该符号链接.如果您需要将文档根目录命名为htdocs
,则可以告诉Symfony使用该目录:
However, you don't even need that symlink. If you need the document root to be named htdocs
, you can tell Symfony to use that directory:
在应用程序的composer.json
中,应该有一个条目"symfony-web-dir": "web"
.将值更改为htdocs
,就可以了.您还应该删除web
到htdocs
的符号链接,以免造成混淆.
In the application's composer.json
, there should be an entry "symfony-web-dir": "web"
. Change the value to htdocs
, and you should be fine. You should also remove the symlink from web
to htdocs
, to avoid confusion.
我尚未对此进行测试,但是我希望所有Symfony发行软件包(包括Assetic)都遵守此设置.如果没有Assetic,只需使用htdocs
作为目标参数调用Assetic.
I haven't tested this, but I'd expect all Symfony distribution packages, including Assetic, to respect this setting. If Assetic doesn't, simply call Assetic with htdocs
as target parameter.
并且,您应该从配置中删除read_from
和write_to
参数.无论如何,您的值都是默认值,因此无需对其进行硬编码.
And, you should remove the read_from
and write_to
parameters from your configuration. Your values are the default anyway, so there's no need to hardcode them.
希望这会有所帮助.
这篇关于Symfony2资产:转储错误的write_to路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!