Download the PHP package middlewares/encoder without Composer
On this page you can find all versions of the php package middlewares/encoder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download middlewares/encoder
More information about middlewares/encoder
Files in middlewares/encoder
Package encoder
Short Description Middleware to encode the response body to gzip or deflate
License MIT
Homepage https://github.com/middlewares/encoder
Informations about the package encoder
middlewares/encoder
Middleware to encode the response body to gzip
or deflate
if the Accept-Encoding
header is present and adds the Content-Encoding
header. This package is splitted into the following components:
- GzipEncoder
- DeflateEncoder
You can use the component ContentEncoding
in the middlewares/negotiation to negotiate the encoding to use.
Requirements
- PHP >= 7.2
- A PSR-7 http library
- A PSR-15 middleware dispatcher
Installation
This package is installable and autoloadable via Composer as middlewares/encoder.
GzipEncoder
Compress the response body to GZIP format using gzencode and add the header Content-Encoding: gzip
.
Note: The response body is encoded only if the header contains the value gzip
in the header Accept-Encoding
.
Optionally, you can provide a Psr\Http\Message\StreamFactoryInterface
that will be used to create the response body. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.
DeflateEncoder
Compress the response body to Deflate format using gzdeflate and add the header Content-Encoding: deflate
.
Note: The response body is encoded only if the header contains the value deflate
in the header Accept-Encoding
.
Optionally, you can provide a Psr\Http\Message\StreamFactoryInterface
that will be used to create the response body. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.
Common Options
contentType
This option allows the overring of the default patterns used to detect what resources are already compressed.
The default pattern detects the following mime types text/*
, application/json
, image/svg+xml
and empty content types as compressible. If the pattern begins with a forward slash /
it is tested as a regular expression, otherwise its is case-insensitive string comparison.
Please see CONTRIBUTING for contributing details.
The MIT License (MIT). Please see LICENSE for more information.
All versions of encoder with dependencies
php Version ^7.2 || ^8.0
middlewares/utils Version ^3.0
psr/http-server-middleware Version ^1.0