adriansuter/psr7-minify-middleware
Composer 安装命令:
composer require adriansuter/psr7-minify-middleware
包简介
PSR-7 Middleware that minifies the response body (HTML Minify).
关键字:
README 文档
README
Simple PSR-7 Middleware that minifies the response body. This middleware can be used to minify the html output.
By default, all textarea and pre sections would not be minified (ignored). This can be customized.
Installation
composer require adriansuter/psr7-minify-middleware
Usage
The constructor of this middleware has two parameters:
- A callback that returns a new object implementing the
Psr\Http\Message\StreamInterfacein 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'].
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:
$app->add( new Minify( function () { return new Body(fopen('php://temp', 'r+')); }, ['script', 'textarea', 'pre', 'code'] ) );
Testing
- Unit tests:
$ vendor/bin/phpunit
统计信息
- 总下载量: 73
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-07