PHP code example of mathiasreker / php-script-cache

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

    

mathiasreker / php-script-cache example snippets




use MathiasReker\PhpScriptCache\ScriptCache;

s/js')
    ->doMinify()
    ->add([
        'src' => [
            'https://example1.com/script.js',
            'https://example2.com/script.js'
        ], // multiple scripts will get bundled
    ])
    ->add([
        'src' => ['https://example3.com/script.js'],
    ])
    ->build();



use MathiasReker\PhpScriptCache\ScriptCache;

 . '/assets/js')
    ->add([
        'src' => [
            'https://example1.com/script.js',
            'https://example2.com/script.js'
        ],
    ])
    ->add([
        'src' => ['https://example3.com/script.js'],
        'id' => 'test',
        'defer' => '',
    ])
    ->fetch();

 // Result: <script src="/assets/js/c5a80e42.js?v=ec25a610"></script><script src="/assets/js/c5a80e42.js?v=539e4fd1" id="test" defer></script>

$result = new ScriptCache();

$result->setPath(__DIR__ . '/assets/js');

$result->doMinify();

$result->add(['src' => ['https://example.com/script.js']]);

$result->build();

$result->fetch();
bash
docker exec -it php-script-cache bash