lablnet / minify
PHP Minify 包。
1.0
2020-02-23 10:22 UTC
This package is auto-updated.
Last update: 2024-09-23 20:53:52 UTC
README
使用php压缩代码
需求
- PHP 7(推荐7.3)。
- Composer。
安装
安装此包非常简单,首先确保您安装了正确的PHP版本和Composer,然后在终端/命令提示符中运行: composer require lablnet/minify
特性
- 压缩HTML
- 压缩CSS
- 压缩JavaScript
示例
<?php # index.php require_once '../vendor/autoload.php'; $minify = new Minify(); $file = $minify->htmlMinify('test.html'); $file = $minify->cssMinify("test.html"); $file = $minify->javascriptMinify("test.html"); var_dump($file);
test.html
<!DOCTYPE html> <html> <head> <title>Im not mainfied</title> <style type="text/css"> /*im comments in css block */ body { background-color: black; color: white; /*display: inline-flex;*/ } </style> </head> <body> <h1>Im heading</h1> <p>Im paragraph</p> <p id='demo'></p> <!-- Im html comments --> </body> <script type="text/javascript"> /* im script */ document.getElementById('demo').innerHTML = 'Hello JavaScript'; </script> </html>
方法
htmlMinify($file, $type)
压缩HTML代码,$file
文件路径或代码,$type
支持,文件,代码。cssMinify($file, $type)
压缩CSS代码,$file
文件路径或代码,$type
支持,文件,代码。javascriptMinify($file, $type)
压缩JS代码,$file
文件路径或代码,$type
支持,文件,代码。
贡献
还有很多工作要做,所以请随时为开源项目贡献 PR
许可证
MIT
支持
37x6PA4qtPu2fQnYdW5U7jztYhbchASpBV
非常感谢。
免责声明
对于任何非法使用我不承担责任