Released 7 years ago , Last update 7 years ago

PhpMinify is a tool that can be used to minify the size of PHP scripts.

Please note that this will NOT make files faster to execute, the only reason why you might want to use it is to distribute smaller files or to remove comments.

  • 5 5
  • 4 2
  • 3 2
  • 2 0
  • 1 0
9 Reviews Read Reviews


14 day 14-day money-back guarantee


Personal License

  • Perpetual license

  • 1 site, unlimited servers

  • No distribution (hosted use only)

  • Commercial use

Basic Usage

Here is the basic usage:

require_once( dirname(dirname(__FILE__)) . '/library/PhpMinify.php' );

try {
    $minifier = new PhpMinify();
} catch (PhpMinify_Exception $ex) {
    echo 'ERROR: ' . $ex->getMessage();

Note: A similar script already exists in the tests/ directory in the package. You can just put your input files in the tests/input/ directory and run the index.php file. It will minify all PHP files and put the results in tests/output/ directory.


  • PHP 5


  • Support for subdirectories
  • Support for patterns to skip


Options are given to the constructor like this:

$options = array(
    // input path, it should be absolute
    PhpMinify::OPT_INPUT_PATH => dirname(__FILE__) . '/input/',
    // output path, it should be absolute
    PhpMinify::OPT_OUTPUT_PATH => dirname(__FILE__) . '/output/',
    // input patterns to match, any of the  patterns must be matched in order to minify
    // items are defined as input parameters for preg_match()
    PhpMinify::OPT_INPUT_PATTERNS => array('/\.php$/'),
    // skip patterns to match, if any of the  patterns must be matched, the target is skipped
    // items are defined as input parameters for preg_match()
    PhpMinify::OPT_SKIP_PATTERNS => array('/^\./'),
    // track the list of minified files, disable if there are too many files and don't care which files were minified
    PhpMinify::OPT_TRACK_MINIFIED => true,
    // strip tabulation, this CAN change the value of multiline strings from code, by default it's disabled
    PhpMinify::OPT_STRIP_TABULATION => false

try {
    $minifier = new PhpMinify($options);
} catch (PhpMinify_Exception $ex) {
    echo 'ERROR: ' . $ex->getMessage();


Please see the PhpMinify documentation.

2 licenses, starting from From » FREE View Licenses

Get A Quote

What do you need?
  • Custom development
  • Integration
  • Customization / Reskinning
  • Consultation
When do you need it?
  • Soon
  • Next week
  • Next month
  • Anytime

Thanks for getting in touch!

Your quote details have been received and we'll get back to you soon.

Or enter your name and Email