arjanschouten / htmlminifier
基于PHP的Html压缩工具,支持Laravel/Lumen。此工具可大幅减小您的应用程序大小!
0.0.2
2016-03-21 16:59 UTC
Requires
- php: >=5.6
- illuminate/console: 5.1.*|5.2.*
- illuminate/contracts: 5.1.*|5.2.*
- illuminate/filesystem: 5.1.*|5.2.*
- illuminate/support: 5.1.*|5.2.*
Requires (Dev)
- laravel/homestead: ^2.1
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-09-26 00:40:55 UTC
README
此包仍处于Beta版本!请谨慎使用!
HtmlMinifier
安装
让composer为我们处理繁琐的工作!
composer require arjanschouten/htmlminifier
Laravel 5.*
可以通过运行以下命令安装基于此压缩工具的Laravel包:
composer require arjanschouten/laravelhtmlminifier
使用composer的普通PHP项目
如果您不使用PHP框架,可以使用以下代码使用压缩工具:
//include the composer autoloader require __DIR__ . '/vendor/autoload.php'; // create a minify context which will be used through the minification process $context = new MinifyContext(new PlaceholderContainer()); // save the html contents in the context $context->setContents('<html>My html...</html>'); $minify = new Minify(); // start the process and give the context with it as parameter $context = $minify->run($context); // $context now contains the minified version $minifiedContents = $context->getContents();
选项
此压缩工具有一些压缩选项,例如:
您可以通过以下方式启用各种压缩选项:
... $options = [ 'whitespace' => false, 'remove-defaults' => true, ]; $minify->run($context, $options);
这将禁用whitespace
并启用remove-defaults
。
贡献
欢迎贡献。请阅读CONTRIBUTING.md 说明书。
测试
HtmlMinifier使用phpunit
进行测试。您可以使用vendor/bin/phpunit
运行测试。
许可证
此包根据MIT许可证授权。
创建者和维护者
此包由Arjan Schouten创建和维护。