Home >Backend Development >PHP Tutorial >symfony输出js和css文件,求大神指导为什么会报错了?

symfony输出js和css文件,求大神指导为什么会报错了?

WBOY
WBOYOriginal
2016-06-06 20:19:371128browse

symfony输出js和css文件,求大神指导为什么会报错了?

symfony输出js和css文件,求大神指导为什么会报错了?

求指导!!!

回复内容:

symfony输出js和css文件,求大神指导为什么会报错了?

symfony输出js和css文件,求大神指导为什么会报错了?

求指导!!!

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

<code>$ composer require symfony/assetic-bundle</code>

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

<code>// app/AppKernel.php

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

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

        // ...
    }
}</code>

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

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

# ...
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn