1. Go to this page and download the library: Download boyo/asset-cdn 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/ */
' 'paths' => [
'js',
'css'
],
]
/*
* This config would try to find:
* '/var/www/html/public/js'
* '/var/www/html/public/css'
* but also any other 'js' or 'css' path e.g.
* '/var/www/html/public/vendor/js'
* '/var/www/html/public/vendor/css'
* You could explicitly exclude paths later
*/
' 'files' => [
'js/app.js',
],
],
/*
* This config would try to find:
* '/var/www/html/public/js/app.js'
* but also any other file that matches the path + filename e.g.
* '/var/www/html/public/vendor/js/app.js'
* You could explicitly exclude these files later
*/
' 'extensions' => [
'*.js',
'*.css',
],
],
/*
* Patterns can be globs, strings, or regexes
*/
' ],
],
// config/asset-cdn.php
[
'filesystem' => [
'disk' => 'asset-cdn',
'options' => [
'ACL' => 'public-read', // File is available to the public, independent of the S3 Bucket policy
'CacheControl' => 'max-age=31536000, public', // Sets HTTP Header 'cache-control'. The client should cache the file for max 1 year
],
],
]