PHP code example of bissolli / php-css-js-minifier
1. Go to this page and download the library: Download bissolli/php-css-js-minifier 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/ */
bissolli / php-css-js-minifier example snippets
$minifier = new \Bissolli\PhpMinifier\Minifier();
// You can load external assets
$minifier->addCssFile('https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap-reboot.css');
// Use relative path to add the file
$minifier->addCssFile('./data/style1.css');
// Full path is also accepted
$minifier->addCssFile('/{FULL_PATH}/php-css-js-minifier/examples/data/style2.css');
// Array is also allowed
$minifier->addCssFile([
'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap-reboot.css',
'./data/style1.css',
'/{FULL_PATH}/php-css-js-minifier/examples/data/style2.css'
]);
// As CSS files, you can load full path, relative and external links.
// Array is also allowed
$minifier->addJsFile('./data/script1.js');
$minifier->addJsFile('/{FULL_PATH}/php-css-js-minifier/examples/data/script2.js');
// Minify and save css and js files
// Output: ./app.min.css & ./app.min.js
$output = $minifier->minify()->output('./', 'app.min');
// Working with Css only
$output = $minifier->minifyCss()->outputCss('./app.min.css');
// Working with Js only
$output = $minifier->minifyJs()->outputJs('./app.min.js');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.