项目作者: Mecanik

项目描述 :
Zend Framework 3 Speed Optimization Module
高级语言: PHP
项目地址: git://github.com/Mecanik/ZF3Turbo.git
创建时间: 2019-11-18T18:04:01Z
项目社区:https://github.com/Mecanik/ZF3Turbo

开源协议:Apache License 2.0

下载


ZF3Turbo - Zend Framework 3 Speed Optimization Module

Latest Stable Version
License
Total Downloads


  1. ! Zend Framework is now Laminas.
  2. ! Please use my other package called Laminas Turbo Speed for Laminas project which is up to date.

Zend Framework is now Laminas: https://www.zend.com/blog/evolution-zend-framework-laminas-project

Laminas Turbo Speed: https://github.com/Mecanik/laminas-turbo-speed


Description

Module to supercharge your website performance by minifying/compressing HTML, inline content and pushing assets via HTTP/2. This module works for HTML5 type for now, do not use with XHTML.

Current Features:

  • Events registered via ListenerAggregateInterface
  • Easy to switch on/off any specific feature or the whole module
  • Ability to force https for all routes (via onRoute)
  • Ability to minify inline javascript (removes comments, spaces)
  • Ability to minify inline stylesheet (removes comments, spaces, CDATA, line breaks)
  • Ability to minify HTML (removes comments, spaces, line breaks)
  • Ability to push scripts via HTTP/2
  • Ability to push stylesheets via HTTP/2
  • Ability to push images via HTTP/2
  • PHP 7 friendly (and required)
  • Does not “break” your pages/content
  • Superfast processing, no cpu overhead (regex patterns have been optimised to be very fast)
  • No other dependencies (than Zend Framework 3)

Planned Features:

  • Caching via Redis
  • Caching via Memcached
  • Caching via CDN (push/pull)
  • Better HTML, JS, CSS minify
  • More…

Installation

Installation is done via Composer:

  1. composer require mecanik/zf3turbo

Module Configuration

Create config/autoload/zf3turbo.global.php with the content:

  1. <?php
  2. return [
  3. 'zf3turbo' => [
  4. // Completely enable/disable all functionality
  5. 'enabled' => true,
  6. // Control current engine options
  7. 'engine_options' => [
  8. // Force all routes to https:// and choose redirect http code
  9. // Recommended redirect_code is 301
  10. 'ssl' => [
  11. 'enabled' => false,
  12. 'redirect_code' => 301,
  13. ],
  14. 'html_minifier' => [
  15. // Completely enable/disable all functionality
  16. 'enabled' => true,
  17. // remove HTML comments (not containing IE conditional comments)
  18. // Recommended: true
  19. 'remove_comments' => true,
  20. // remove whitespaces and line breaks
  21. // Recommended: true
  22. 'remove_whitespaces' => true,
  23. // remove trailing slash from void elements
  24. // Optional
  25. 'remove_trailing_slashes' => true,
  26. ],
  27. // Soon...
  28. 'html_cache' => [],
  29. 'css_minifier' => [
  30. // Completely enable/disable all functionality
  31. 'enabled' => true,
  32. // This will minify inline <style></style> tags, will strip comments and white spaces and new lines.
  33. // Warning: Might break some styles, use with caution.
  34. 'minify_inline_styles' => true,
  35. ],
  36. 'js_minifier' => [
  37. // Completely enable/disable all functionality
  38. 'enabled' => false,
  39. // This will minify inline <script></script> tags, will strip comments and white spaces and new lines.
  40. // Warning: Might break some styles, use with caution.
  41. 'minify_inline_js' => true,
  42. ],
  43. // Push assets via HTTP/2 to the browser
  44. 'http2_push' => [
  45. // Completely enable/disable all functionality
  46. 'enabled' => true,
  47. // Push all local CSS files via HTTP/2
  48. 'push_css' => true,
  49. // Push all local JS files via HTTP/2
  50. 'push_js' => true,
  51. // Push all local IMG files via HTTP/2
  52. 'push_images' => true,
  53. ],
  54. ],
  55. ],
  56. ];

Module Usage

Load the module (in any order):

  1. 'Mecanik\ZF3Turbo'

That’s all for now, enjoy!