steffenbrand / html-compress-middleware
There is no license information available for the latest version (v1.0.0) of this package.
HTML Compress Middleware
v1.0.0
2018-03-25 01:36 UTC
Requires
- php: >=7.1
- psr/container: ^1.0
- psr/http-message: ^1.0.1
- psr/http-server-middleware: ^1.0
- wyrihaximus/html-compress: ^1.4
- zendframework/zend-diactoros: ^1.7
Requires (Dev)
- phpunit/phpunit: ^7.0
This package is auto-updated.
Last update: 2024-11-29 04:52:29 UTC
README
HTML Compress Middleware
PSR-15 compliant middleware to compress html responses.
How to install
composer require steffenbrand/html-compress-middleware
How to use with Zend Expressive 3
Add the middleware to your config/pipeline.php
/** * Setup middleware pipeline: */ return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void { // The error handler should be the first (most outer) middleware to catch // all Exceptions. $app->pipe(ErrorHandler::class); $app->pipe(HtmlCompressMiddleware::class); ... }
Add the middleware to your config/autoload/dependencies.global.php
Or use it as a routed middleware, if you don't want the middleware to be invoked on certain routes.
return [ // Provides application-wide services. // We recommend using fully-qualified class names whenever possible as // service names. 'dependencies' => [ ... 'factories' => [ // Fully\Qualified\ClassName::class => Fully\Qualified\FactoryName::class, \SteffenBrand\HtmlCompressMiddleware\HtmlCompressMiddleware::class => \SteffenBrand\HtmlCompressMiddleware\HtmlCompressMiddlewareFactory::class, ], ], ];
Enable compression
To enable compression disable the development mode.
HTML compression is only meant for production.
composer development-disable
Disable compression
To disable compression enable the development mode.
HTML compression will not run in development mode.
composer development-enable
Or provide your own development-mode settings by editing the file config/autoload/development.local.php.dist