abordage / laravel-html-min
HtmlMin 是一个非常简单(且非常快速)的 Laravel HTML 压缩包
0.2.1
2024-03-23 19:20 UTC
Requires
- php: >=7.4
- abordage/html-min: ^0.2.1
- illuminate/support: ^8.0 || ^9.0 || ^10.0 || ^11.0
Requires (Dev)
- ext-json: *
- friendsofphp/php-cs-fixer: ^3.0
- nunomaduro/collision: ^5.0 || ^6.0 || ^7.0 || ^8.0
- nunomaduro/larastan: ^1.0 || ^2.0
- orchestra/testbench: ^6.0 || ^7.0 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.6 || ^10.0
This package is auto-updated.
Last update: 2024-09-08 20:04:49 UTC
README
HtmlMin: Laravel 的 HTML 压缩包
非常简单(且非常快速)的 HTML 压缩。
特性
- 移除额外空格
- 移除 HTML 注释(正确处理
livewire/livewire
注释) - 跳过
textarea
、pre
和script
元素 - 非常快速。查看基准测试
要求
- PHP 7.4 - 8.3
- Laravel 8.x - 11.x
安装
您可以通过 composer 安装此包
composer require abordage/laravel-html-min
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="html-min-config"
使用方法
要启用压缩,只需注册中间件
// app/Http/Kernel.php protected $middleware = [ 'web' => [ // other middleware \Abordage\LaravelHtmlMin\Middleware\HtmlMinify::class, ], // ... ];
就这些了。您还可以在 config/html-min.php
中更改设置(可选)
配置
return [ /* |-------------------------------------------------------------------------- | Enable Html Min |-------------------------------------------------------------------------- */ 'enable' => env('HTML_MINIFY', true), /* |-------------------------------------------------------------------------- | Find DOCTYPE in document |-------------------------------------------------------------------------- */ 'find_doctype_in_document' => true, /* |-------------------------------------------------------------------------- | Remove whitespace between tags |-------------------------------------------------------------------------- */ 'remove_whitespace_between_tags' => true, /* |-------------------------------------------------------------------------- | Remove blank lines in script elements |-------------------------------------------------------------------------- */ 'remove_blank_lines_in_script_elements' => false, ];
基准测试
测试
composer test:all
或者
composer test:phpunit composer test:phpstan composer test:phpcsf
或者查看https://github.com/abordage/laravel-html-min/actions/workflows/tests.yml
反馈
如果您有任何反馈、评论或建议,请随时在此存储库中提交问题。
贡献
请参阅CONTRIBUTING 获取详细信息。
致谢
许可协议
MIT 许可协议(MIT)。有关更多信息,请参阅许可文件。