1 个回答

使用"javascripts"和"stylesheets"需要提前用Composer安装一个Symfony的官方Bundle,叫做Assetic(2.8版本以后,默认框架没有安装该Bundle,需要自行安装):

$ composer require symfony/assetic-bundle

然后,在AppKernel.php中启用该Bundle:

// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    // ...

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
        );

        // ...
    }
}

最后,进行一些必要的配置:

# app/config/config.yml
assetic:
    debug:          '%kernel.debug%'
    use_controller: '%kernel.debug%'
    filters:
        cssrewrite: ~

# ...
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题