PHP code example of hx / fusion-php

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

    

hx / fusion-php example snippets



$file = Hx\Fusion::file('/path/to/file.scss');


$file = Hx\Fusion::file('file.scss', '/path/to'); // Equivalent to previous example



// Test if the represented file exists
echo $file->exists() ? 'found' : 'missing';

// The path of the file, relative to the given base bath
echo $file->path();

// The file's base path
echo $file->basePath();

// The file's absolute path (base + path)
echo $file->absolutePath();

// The file's content type (in this case, "text/css")
echo $file->contentType();



// Raw contents of the file
echo $file->raw();

// Filtered version of the file (processed by Sass, in this case)
echo $file->filtered();

// Filtered AND minified version of the file
echo $file->compressed();



// Manually
$files = new Hx\Fusion\AssetCollection([
    Hx\Fusion::file('a.coffee'),
    Hx\Fusion::file('b.coffee'),
    Hx\Fusion::file('c.coffee')
]);

// Using the glob() method
$files = Hx\Fusion::glob('*.coffee');

// $files is an instance of Hx\Fusion\AssetCollection, which extends ArrayObject
echo count($files);     // 3
echo $files[0]->path(); // a.coffee



$file = Hx\Fusion::file('c.coffee');

$deps = $file->dependencies();

echo count($deps);     // 2
echo $deps[0]->path(); // a.coffee
echo $deps[1]->path(); // b.coffee

$all = $file->dependenciesAndSelf();

echo count($all);     // 3
echo $all[2]->path(); // c.coffee


echo $all->compressed();