mb-webdev / optimization-bundle
此包已被废弃,不再维护。未建议替代包。
一个专门用于简化头部管理和HTML压缩的优化包
1.0.2
2016-01-29 10:39 UTC
Requires
- php: >=5.3.2
- symfony/framework-bundle: 2.*
This package is not auto-updated.
Last update: 2022-02-01 12:55:09 UTC
README
MBOptimizationBundle 是一个小巧简单的包,它对HTTP响应进行了一些优化,例如添加安全头部、压缩HTML等...
安装
步骤 1:Composer
首先,您需要将 MB/optimization-bundle
添加到 composer.json
{ "require": { "mb/optimization-bundle": "dev-master" } }
注意:用此包的最新版本替换 dev-master
步骤 2:AppKernel
将包注册到 Symfony AppKernel 中
// app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( ... new MB\Bundle\OptimizationBundle\MBOptimizationBundle() ); return $bundles; } }
步骤 3:配置
在配置文件中定义包的配置
# app/config/config.yml mb_optimization: html_compress: false # optional : compress html output (spaghetti code) x_frame_options: enabled: false # required : enable/disable X-Frame-Options header value: SAMEORIGIN # optional : value of this header attribute (default value : "SAMEORIGIN") x_xss_protection: enabled: false # required : enable/disable X-XSS-Protection header value: "1; mode=block" # optional : value of this header attribute (default value : "1; mode=block") content_security_policy: enabled: false # required : enable/disable Content-Security-Policy header value: # optional : array of values for this header attribute (automatically add "self" to the list of sources) - "source1.com" - "source2.com" - "*.source3.com"