symfony3.4默认并没有安装assetic,所以需要我们手动来安装
首先安装命令:
1 |
$ composer require symfony/assetic-bundle |
注册bundle
1 2 3 4 5 6 7 |
//app/AppKernel.php public function registerBundles() { $bundles = array( *// ...* new Symfony\Bundle\AsseticBundle\AsseticBundle(), ); *// ...* } |
添加配置
1 2 3 4 5 6 |
//app/config/config.yml 添加配置 assetic: debug: '%kernel.debug%' use_controller: '%kernel.debug%' filters: cssrewrite: ~ |
使用看看吧:
1 2 3 4 5 |
{% block includes %} <link href="{{ asset('css/libs/bootstrap.min.css') }}" type="text/css" rel="stylesheet"/> <link href="{{ asset('css/libs/bootstrap.min.css') }}" type="text/css" rel="stylesheet"/> <link href="{{ asset('css/main.css') }}" type="text/css" rel="stylesheet"/> {% endblock %} |