1. Go to this page and download the library: Download jalle19/php-yui-compressor 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/ */
jalle19 / php-yui-compressor example snippets
$yui = new \YUI\Compressor();
// Read the uncompressed contents
$css = file_get_contents('styles.css');
$script = file_get_contents('script.js');
// Compress the CSS
$yui->setType(\YUI\Compressor::TYPE_CSS);
$optimizedCss = $yui->compress($css);
// Compress the JavaScript
$yui->setType(\YUI\Compressor::TYPE_JS);
$optimizedScript = $yui->compress($script);
// javaPath defauls to "java" which means it has to be in the path. If that's
// not the case we can override it like this.
$yui = new \YUI\Compressor(array(
'javaPath'=>'/usr/bin/java',
'line-break'=>80,
'disable-optimizations'=>true,
));
// Read the uncompressed contents
$css = file_get_contents('styles.css');
$script = file_get_contents('script.js');
// The "disable-optimizations" option is JavaScript-specific so it won't apply
// here...
$yui->setType(\YUI\Compressor::TYPE_CSS);
$optimizedCss = $yui->compress($css);
// ...but here it will
$yui->setType(\YUI\Compressor::TYPE_JS);
$optimizedScript = $yui->compress($script);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.