inilim/php-code-minifier 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

inilim/php-code-minifier

Composer 安装命令:

composer require inilim/php-code-minifier

包简介

Is fork. PHP Code Minifier is a tool that allows you to minify your PHP code.

README 文档

README

⭐ Star us on GitHub — it motivates us a lot! 😀

PHP Code Minifier is a tool that allows you to minify your PHP code. It removes all the unnecessary spaces and new lines from your PHP code and then split all the PHP code in the given .php file into one line.

I don't know why you would want to do this, but feel free to use it if you want to 😄

Installation

You can install PHP Code Minifier using Composer:

composer require php-code-minifier/php-code-minifier

Usage

Keep in mind, PHP code inside short opening PHP tags (<?) will not be minified. Such code parsed by PHP as HTML and will be ignored by the minifier.

<?php

// Create a new instance of minifier via the factory
$phpCodeMinifier = \PhpCodeMinifier\MinifierFactory::create();

// Or, feel free to instantiate the minifier directly via new,
// but keep in mind, it's requires the PhpFileValidator and PhpTokenizer instances 
$phpCodeMinifier = new \PhpCodeMinifier\PhpMinifier(
    new \PhpCodeMinifier\Validator\PhpFileValidator(),
    new \PhpCodeMinifier\PhpTokenizer()
);

// Okay, the hardest part is done, now you can minify your PHP code
$phpCodeMinifier->minifyFile('/path/to/your/file.php');

// Or, if you already have the PHP code in a string, you can minify it with the following:
$phpCode = '<?php echo "Hello World!";';
$phpCodeMinifier->minifyString($phpCode);

// Both this action can store the minified code in a file. Just use the following:

$phpCodeMinifier->minifyStringToFile($phpCode, '/path/to/your/file.php');
// Or
$phpCodeMinifier->minifyFileToFile('/path/to/your/file.php', '/path/to/your/file.php');

Contributing

Feel free to contribute to this project by submitting a pull request to add more features or fix bugs (or maybe add some bug? who knows 👌).

I'm going to write some contributing notes soon.

License

PHP Code Minifier is licensed under the MIT License - see the LICENSE file for details.

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-02