我正在尝试 symfony2 及其与 compass/sass 的资产。但是当我仅在开发环境中时,编译的 css 文件中出现错误:
/*
[exception] 500 | Internal Server Error | Symfony\Component\Debug\Exception\ContextErrorException
[message] Warning: file_put_contents(): Filename cannot be empty in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
[1] Symfony\Component\Debug\Exception\ContextErrorException: Warning: file_put_contents(): Filename cannot be empty in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
at n/a
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
at Symfony\Component\Debug\ErrorHandler->handle('2', 'file_put_contents(): Filename cannot be empty', '/Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php', '312', array('asset' => object(FileAsset), 'root' => '/Users/kklaus/Workspace/Symfony/app/../web', 'path' => 'bundles/webdevblog/sass/style.scss', 'loadPaths' => array('/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass'), 'tempDir' => '/private/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T', 'compassProcessArgs' => array('/usr/bin/ruby', '/usr/bin/compass', 'compile', '/private/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T'), 'pb' => object(ProcessBuilder), 'optionsConfig' => array('additional_import_paths' => array('/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass'), 'sass_options' => array('cache_location' => '/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T'), 'http_path' => '/images'), 'config' => array('additional_import_paths = [
"/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass"
]', 'sass_options = {
:cache_location => "/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T"
}', 'http_path = "/images"'), 'name' => 'http_path', 'value' => '/images', 'configFile' => false))
in line
at file_put_contents('', 'additional_import_paths = [
"/Users/kklaus/Workspace/Symfony/app/../web/bundles/webdevblog/sass"
]
sass_options = {
:cache_location => "/var/folders/nx/kydlggls2l92jf69_dp_sy5c0000gn/T"
}
http_path = "/images"
')
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/CompassFilter.php line 312
at Assetic\Filter\CompassFilter->filterLoad(object(FileAsset))
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/FilterCollection.php line 62
at Assetic\Filter\FilterCollection->filterLoad(object(FileAsset))
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php line 90
at Assetic\Asset\BaseAsset->doLoad('
body {
background-color: yellow;
}
h2 {
color: green;
}
p {
span {
font-weight: bold;
}
}', null)
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/FileAsset.php line 65
at Assetic\Asset\FileAsset->load()
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/BaseAsset.php line 99
at Assetic\Asset\BaseAsset->dump(null)
in /Users/kklaus/Workspace/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Asset/AssetCache.php line 69
at Assetic\Asset\AssetCache->dump()
in /Users/kklaus/Workspace/Symfony/vendor/symfony/assetic-bundle/Symfony/Bundle/AsseticBundle/Controller/AsseticController.php line 88
at Symfony\Bundle\AsseticBundle\Controller\AsseticController->render('56ff856', '0')
in line
at call_user_func_array(array(object(AsseticController), 'render'), array('56ff856', '0'))
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2844
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2818
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2947
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in /Users/kklaus/Workspace/Symfony/app/bootstrap.php.cache line 2249
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in /Users/kklaus/Workspace/Symfony/web/app_dev.php line 28
*/
当我在 prod 环境中时,它可以工作。CSS文件是正确的:
/* line 2, assetic_compass67JtN2.scss */
body {
background-color: yellow;
}
/* line 7, assetic_compass67JtN2.scss */
h2 {
color: green;
}
/* line 13, assetic_compass67JtN2.scss */
p span {
font-weight: bold;
}
config.yml 中的 Asstetic 配置:
# Assetic Configuration
assetic:
debug: %kernel.debug%
use_controller: false
bundles: [ ]
#java: /usr/bin/java
ruby: /usr/bin/ruby
filters:
cssrewrite: ~
sass:
bin: /usr/bin/sass
compass:
bin: /usr/bin/compass
有人知道错误在哪里以及为什么它在开发中不起作用吗?