mechanik / zf3turbo
此包已被弃用且不再维护。未建议替代包。
Zend Framework 3 速度优化模块
1.0.0
2019-11-18 18:14 UTC
Requires
- php: ^7.0
- zendframework/zend-mvc: ^3.1
Conflicts
- zendframework/zendframework: <3.0.0
This package is auto-updated.
Last update: 2020-07-23 10:59:46 UTC
README
! Zend Framework is now Laminas. ! Please use my other package called Laminas Turbo Speed for Laminas project which is up to date.
Zend Framework 现已更名为 Laminas: https://www.zend.com/blog/evolution-zend-framework-laminas-project
Laminas Turbo Speed: https://github.com/Mecanik/laminas-turbo-speed
描述
通过最小化/压缩 HTML、内联内容和通过 HTTP/2 推送资源来提升网站性能的模块。该模块目前适用于 HTML5 类型,请勿与 XHTML 一起使用。
当前功能
- 通过 ListenerAggregateInterface 注册的事件
- 易于开启/关闭任何特定功能或整个模块
- 强制所有路由使用 https(通过 onRoute 实现)
- 能够最小化内联 JavaScript(移除注释和空格)
- 能够最小化内联 CSS(移除注释、空格、CDATA、换行符)
- 能够最小化 HTML(移除注释、空格、换行符)
- 能够通过 HTTP/2 推送脚本
- 能够通过 HTTP/2 推送样式表
- 能够通过 HTTP/2 推送图片
- PHP 7 兼容(且必需)
- 不会“破坏”你的页面/内容
- 超快处理,无 CPU 开销(正则表达式模式已优化为非常快)
- 没有其他依赖(除了 Zend Framework 3)
计划功能
- 通过 Redis 缓存
- 通过 Memcached 缓存
- 通过 CDN(推送/拉取)缓存
- 更好的 HTML、JS、CSS 最小化
- 更多...
安装
通过 Composer 进行安装
composer require mecanik/zf3turbo
模块配置
创建 config/autoload/zf3turbo.global.php,内容如下
<?php return [ 'zf3turbo' => [ // Completely enable/disable all functionality 'enabled' => true, // Control current engine options 'engine_options' => [ // Force all routes to https:// and choose redirect http code // Recommended redirect_code is 301 'ssl' => [ 'enabled' => false, 'redirect_code' => 301, ], 'html_minifier' => [ // Completely enable/disable all functionality 'enabled' => true, // remove HTML comments (not containing IE conditional comments) // Recommended: true 'remove_comments' => true, // remove whitespaces and line breaks // Recommended: true 'remove_whitespaces' => true, // remove trailing slash from void elements // Optional 'remove_trailing_slashes' => true, ], // Soon... 'html_cache' => [], 'css_minifier' => [ // Completely enable/disable all functionality 'enabled' => true, // This will minify inline <style></style> tags, will strip comments and white spaces and new lines. // Warning: Might break some styles, use with caution. 'minify_inline_styles' => true, ], 'js_minifier' => [ // Completely enable/disable all functionality 'enabled' => false, // This will minify inline <script></script> tags, will strip comments and white spaces and new lines. // Warning: Might break some styles, use with caution. 'minify_inline_js' => true, ], // Push assets via HTTP/2 to the browser 'http2_push' => [ // Completely enable/disable all functionality 'enabled' => true, // Push all local CSS files via HTTP/2 'push_css' => true, // Push all local JS files via HTTP/2 'push_js' => true, // Push all local IMG files via HTTP/2 'push_images' => true, ], ], ], ];
模块使用
加载模块(按任意顺序)
'Mecanik\ZF3Turbo'
到此为止,祝您使用愉快!