PHP code example of gulch / minify

1. Go to this page and download the library: Download gulch/minify library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gulch / minify example snippets


$minifier = gulch\Minify\Minifier::createDefault();
// default optimizations are: whitespaces remove, html comments remove, minification of css and js code
// above code is equivalent to:
// $minifier = new gulch\Minify\Minifier(
//     new gulch\Minify\Processor\WhitespacesRemover,
//     new gulch\Minify\Processor\HtmlCommentsRemover,
//     new gulch\Minify\Processor\InlineCssMinifier,
//     new gulch\Minify\Processor\InlineJavascriptMinifier,
// );
$minified_code = $minifier->process($code);

$minifier = new gulch\Minify\Minifier(
    new gulch\Minify\Processor\WhitespacesRemover,
    new gulch\Minify\Processor\HtmlCommentsRemover,
    new gulch\Minify\Processor\InlineCssMinifier,
    new gulch\Minify\Processor\InlineJavascriptMinifier,
    new gulch\Minify\Processor\AttributesSimplifier,
    new gulch\Minify\Processor\AttributeQuotesRemover,
);
$minified_code = $minifier->process($code);