PHP code example of axllent / silverstripe-minifier

1. Go to this page and download the library: Download axllent/silverstripe-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/ */

    

axllent / silverstripe-minifier example snippets




use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\View\Requirements;

class PageController extends ContentController
{
    /**
     * Init function
     *
     * @return void
     */
    protected function init()
    {
        parent::init();

        $css[] = 'themes/site/css/file1.css';
        $css[] = 'themes/site/css/file2.css';
        $css[] = 'themes/site/css/file3.css';
        Requirements::combine_files('combined.css', $css);
        Requirements::process_combined_files();

        $js[] = 'themes/site/js/file1.js';
        $js[] = 'themes/site/js/file2.js';
        $js[] = 'themes/site/js/file3.js';
        Requirements::combine_files('combined.js', $js);
        Requirements::process_combined_files();
    }
}