2017 © Pedro Peláez
 

library psr7-minify-middleware

PSR-7 Middleware that minifies the response body (HTML Minify)

image

adriansuter/psr7-minify-middleware

PSR-7 Middleware that minifies the response body (HTML Minify)

  • Monday, October 10, 2016
  • by adriansuter
  • Repository
  • 1 Watchers
  • 1 Stars
  • 44 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PSR-7 middleware to minify the response body

Latest Stable Version ![Build status][Master image] Coverage Status Total Downloads License, (*1)

Simple PSR-7 Middleware that minifies the response body. This middleware can be used to minify the html output., (*2)

By default, all textarea and pre sections would not be minified (ignored). This can be customized., (*3)

Installation

composer require adriansuter/psr7-minify-middleware, (*4)

Usage

The constructor of this middleware has two parameters: - A callback that returns a new object implementing the Psr\Http\Message\StreamInterface in order to be able to minify the content. - The html elements (tag names) that should be ignored. This parameter is optional and defaults to the array ['textarea', 'pre']., (*5)

In Slim 3:

use AdrianSuter\PSR7\Middleware\Minify;
use Slim\Http\Body;

// Create the application $app
// [...]

$app->add(
    new Minify(
        function () {
            return new Body(fopen('php://temp', 'r+'));
        }
    )
);

In order to customize the html elements to be ignored, simply add a second parameter to the constructor:, (*6)

$app->add(
    new Minify(
        function () {
            return new Body(fopen('php://temp', 'r+'));
        },
        ['script', 'textarea', 'pre', 'code']
    )
);

Testing

  • Unit tests: $ vendor/bin/phpunit

The Versions

10/10 2016

dev-master

9999999-dev http://github.com/adriansuter/psr7-minify-middleware

PSR-7 Middleware that minifies the response body (HTML Minify)

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr7 minify

10/10 2016

v0.2

0.2.0.0 http://github.com/adriansuter/psr7-minify-middleware

PSR-7 Middleware that minifies the response body (HTML Minify)

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr7 minify

07/10 2016

v0.1

0.1.0.0 http://github.com/adriansuter/psr7-minify-middleware

PSR-7 Middleware that minifies the response body

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr7 minify

07/10 2016

v0.1-alpha

0.1.0.0-alpha http://github.com/adriansuter/psr7-minify-middleware

PSR-7 Middleware that minifies the response body

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr7 minify