Advanced usage

Minifine exposes a public API for more advanced usages. This may include using different minification schemes or even chaining together several minifion schemes.

Using different minification schemes

To use different minificators (instead of the default ones provided by Minifine) all you have to do is setup the Minifine object using the different minificators:

$minifier = new \Minifine\Minifine('/path/to/resources');
$minifier->appendJsMinifier(new \CustomJsMinifier());
$minifier->appendCssMinifier(new \CustomCssMinifier());

The minifier can now be used using the custom minifiers for CSS and javascript files.

All (custom) minifiers must implement the Minifine\Minifier\Minifier interface which has a single method with a single parameter:

Minifine\Minifier\Minifier::minify(string $data)

The $data parameter is the actual data that needs to be minified.

Chaining minifcations

To chain minifications the public API contains four methods being appendJsMinifier(), prependJsMinifier(), appendCssMinifier() and prependCssMinifier()

When multiple minifiers are defined for a specific type of resource (CSS or javascript) they will be chained together and ran after eachother.

All (custom) minifiers must implement the Minifine\Minifier\Minifier interface which has a single method with a single parameter:

Minifine\Minifier\Minifier::minify(string $data)

The $data parameter is the actual data that needs to be minified.