marko9827/phpminify

压缩 JS、CSS、HTML 字符串或文件

dev-main 2021-12-15 11:00 UTC

This package is auto-updated.

Last update: 2024-09-15 17:29:08 UTC


README

压缩 JS、CSS、HTML 字符串或文件。

CI

PHP Composer

非常简单。使用以下代码。

Composer

  1. 安装 Composer
  2. 输入 composer require marko9827/minify
  3. 享受

用法

 use marko9827\minify\Minify as MinifyMinify;
 
 $content = file_get_contents("$path/file.example"); // .example = .js/.css/.html
 // or
 $content = "var a = 0;  return a + 2;"; //js example
 $content = "body { display: flex; }"; // css example
 $content = "... <body> <div id='example_div'><p>Html Example</p></div>  ..."; // html example

 $minify = new Minify($content);
 echo $minify;
 // or
 echo new Minify($content);

返回压缩后的内容

有效的文件扩展名或 MIME 类型