Assetic:Writer不会在调试模式下生成所有文件

时间:2012-05-14 14:39:32

标签: assetic

我正在尝试将资产与Twig连接(在Zend上)。它似乎适用于debug = false,但我无法理解它对开发的作用。

基本上,在调用时:

{% javascripts 'static/js/*.js' %}
    <p>{{asset_url}}</p>
{% endjavascripts %}

它输出生成的javascript文件名列表(很不错):

js/d19cc07_part_1_jquery-1.7.2.min_6.js
js/d19cc07_part_1_jquery.cookie_7.js
js/d19cc07_part_1_jquery.jeditable.mini_8.js

但这些文件不是由writter生成的(它只生成js / d19cc07.js)。对于debug = false,它只输出一个文件名并正确呈现它。

那我在这里错过了什么?

以下是我如何初始化它:

    //Assetic
    $factory = new \Assetic\Factory\AssetFactory(APP_BASE_PATH . '/public/');
    $factory->setDebug(true);
    $am = new \Assetic\Factory\LazyAssetManager($factory);

    //enable loading assets from twig templates
    $loader = new \Twig_Loader_Filesystem(array());
    $loader->addPath(APP_BASE_PATH.'/application/templates/default');

    //Init twig
    $twig = new \Twig_Environment($loader);
    $twig->addExtension(new \Assetic\Extension\Twig\AsseticExtension($factory));

    $am->setLoader('twig', new \Assetic\Extension\Twig\TwigFormulaLoader($twig));


    $templates = array('/index/index.html'); //An array containing full paths to my templates

    foreach ($templates as $template) {
        $resource = new \Assetic\Extension\Twig\TwigResource($loader, $template);

        $am->addResource($resource, 'twig');
    }

    //Writer
    $writer = new \Assetic\AssetWriter(APP_BASE_PATH . '/public/static/assetic');
    $writer->writeManagerAssets($am);

    echo $twig->render('index/index.html');

1 个答案:

答案 0 :(得分:0)

我最终将Symfony控制台连接到我的Zend项目,并稍微采用了资产的DumpCommand来完成这项工作(通过传递我的DI containter版本和指定的AsseticManager)。