PHP code example of hjgreen / silverstripe-laravel-mix

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

    

hjgreen / silverstripe-laravel-mix example snippets


use HJGreen\SilverstripeLaravelMix\Mix;
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\Director;
use SilverStripe\View\Requirements;
use SilverStripe\View\ThemeResourceLoader;

class PageController extends ContentController {
    public function init(){
        parent::init();
        
        if (Director::isDev()) {
            Requirements::css(Mix::resolve('/dist/styles.css'));
            Requirements::javascript(Mix::resolve('/dist/index.js'));
        } else {
            $theme = ThemeResourceLoader::inst();
            Requirements::css($theme->findThemedCSS('/dist/styles.css'));
            Requirements::javascript($theme->findThemedJavascript('/dist/index.js'));
        }
    }
}