middlewares/minifier 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

middlewares/minifier

最新稳定版本:v2.1.0

Composer 安装命令:

composer require middlewares/minifier

包简介

Middleware to minify Html, CSS and Javascript responses

README 文档

README

Latest Version on Packagist Software License Testing Total Downloads

Middleware to minify the Html, CSS and Javascript content using wyrihaximus/compress and the following compressors by default:

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/minifier.

composer require middlewares/minifier

Example

Dispatcher::run([
    Middlewares\Minifier::html(),
    Middlewares\Minifier::css(),
    Middlewares\Minifier::js(),
]);

Usage

This middleware minify the code of http responses using any compressor implementing the WyriHaximus\Compress\CompressorInterface. The code format is detected from the Content-Type header, so make sure your responses contains this header (you may want to use middlewares/negotiation for that).

use WyriHaximus\HtmlCompress\Factory;

$compressor = Factory::construct();
$mimeType = 'text/html';

$minifier = new Middlewares\Minifier($compressor, $mimeType);

Optionally, you can provide a Psr\Http\Message\StreamFactoryInterface as third argument to create the response body. If it's not defined, Middleware\Utils\Factory will be used to detect it automatically.

$streamFactory = new MyOwnStreamFactory();

$minifier = new Middlewares\Minifier($compressor, $mimeType, $streamFactory);

Helpers

Three static functions are provided to create instances of this middleware with common configuration for html, css and js responses:

$htmlMinifier = Middlewares\Minifier::html();
$cssMinifier = Middlewares\Minifier::css();
$jsMinifier = Middlewares\Minifier::js();

Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.

统计信息

  • 总下载量: 28.68k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 17
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 17
  • Watchers: 2
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-10-10