steffenbrand/html-compress-middleware

此包最新版本(v1.0.0)没有提供许可信息。

HTML压缩中间件

v1.0.0 2018-03-25 01:36 UTC

This package is auto-updated.

Last update: 2024-08-29 04:20:09 UTC


README

Latest Stable Version Total Downloads Build Status Scrutinizer Code Quality Code Coverage

HTML压缩中间件

PSR-15兼容中间件,用于压缩HTML响应。

Concept

如何安装

composer require steffenbrand/html-compress-middleware

如何与Zend Expressive 3一起使用

将中间件添加到您的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);
    ...
 }

将中间件添加到您的config/autoload/dependencies.global.php
或者如果您不希望在特定路由上调用中间件,可以使用路由中间件

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,
        ],
    ],
];

启用压缩

要启用压缩,请禁用开发模式。
HTML压缩仅适用于生产环境。

composer development-disable

禁用压缩

要禁用压缩,请启用开发模式。
HTML压缩不会在开发模式下运行。

composer development-enable

或者通过编辑文件config/autoload/development.local.php.dist提供您自己的开发模式设置。