PHP code example of granam / web-content-builder

1. Go to this page and download the library: Download granam/web-content-builder 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/ */

    

granam / web-content-builder example snippets


$assetsVersion = new \Granam\WebContentBuilder\AssetsVersion(); // will scan for *.css, *.html and *.md by default,

/** body {
    background-image: url("/img/someone.jpeg");
} */
echo file_get_contents(__DIR__ . '/css/main.css');

$changedFiles = $assetsVersion->addVersionsToAssetLinks(
    __DIR__ /* as document root */,
    ['css' ]/* to document root relative dirs to scan */,
    []/* no dirs to exclude */,
    []/* no exact files to scan */,
    false /* no dry run to change files directly */
);
/** Array (
    [0] => '/home/jaroslav/projects/granam/web-content-builder/css/main.css'
) */
print_r($changedFiles);


/** body {
    background-image: url("/img/someone.jpeg?version=664a924915e642c7dc89af370114629a");
} */
echo file_get_contents(__DIR__ . '/css/main.css');
echo md5_file(__DIR__ . '/img/someone.jpeg'); // 664a924915e642c7dc89af370114629a