Important facts about commercial licenses

  • Licenses are perpetual. They do not expire and do not need to be renewed.
  • Licenses can be upgraded. You can upgrade to a more expensive license later paying only the difference in cost.
  • Pay attention to the distribution type - Hosted (sites / servers), binary (applications) or source (includes all the others). Choose according to your needs (more below).
  • All licenses allow commercial use unless otherwise indicated.
  • Read the full license by clicking on the icon.
  • Read more about licenses in our handy license guide.
Free

Personal License

1 site, unlimited servers No source distribution
$9

Developer License

Unlimited projects Source and binary distribution
You need to log-in or create an account
  • Create an account
  • Log-in
  • Please use your real name.
  • Account activation link will be sent to this address.
  • Minimum 8 characters

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

  • Released: Nov 14, 2011
    Last Update: Nov 13, 2011
  • Language: PHP
  • Time / costs savings: 4h / $240 *
(9 ratings)

PhpMinify

PhpMinify
Developed by Cristian Radu, Released Nov 14, 2011

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

PHP

Tags: compact , compress , minify , minify code

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.

Back to top

Basic Usage

Here is the basic usage:

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

try {
    $minifier = new PhpMinify();
    $minifier->run();
} 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.

Back to top

Requirements

  • PHP 5
Back to top

Features

  • Support for subdirectories
  • Support for patterns to skip
Back to top

Configuration

Options are given to the constructor like this:

<?php
$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);
    $minifier->run();
} catch (PhpMinify_Exception $ex) {
    echo 'ERROR: ' . $ex->getMessage();
}
?>
Back to top

Documentation

Please see the PhpMinify documentation.

View all 7 reviews »

User Reviews

  • Badea Sorin 1 year ago
    very useful . helps secure a lot of my projects source code :)
    Flag
    Was this helpful? Yes No
  • t9liu 1 year ago
    Very cool
    Flag
    Was this helpful? Yes No
  • Alex 2 years ago
    It's a very good plugins, easy to use and integrate. Small but very powerfull.
    Flag
    Was this helpful? Yes No
Read all 2 comments »

Questions & Comments


Or enter your name and Email
  • t9liu 1 year ago
    I think it's quite cool and very useful for our project. Thx
  • Daniel Paul 2 years ago
    Nice :)
You must be logged-in to vote. Log-in to your account or register now.