PHP code example of himanverma / cakephp-3.x-assets-bundler
1. Go to this page and download the library: Download himanverma/cakephp-3.x-assets-bundler 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/ */
himanverma / cakephp-3.x-assets-bundler example snippets
/**
* Adds a css file to the file queue
* @param array/string files - string name of a file or array containing multiple string of files
* @param bool immediate - true to immediately process and print the file, false to merge with others
* @param string how - 'link' to print <link>, 'embed' to use <style>...css code...</style>
* @return string - when $immediate=true the tag will be printed, "" otherwise
*/
public function css($files, $immediate=false, $how='link')
/**
* Adds a js file to the file queue
* @param array/string files - string name of a file or array containing multiple string of files
* @param bool immediate - true to immediately process and print the file, false to merge with others
* @param string how - 'link' for <script src="">, 'async' for <script src="" async>, 'embed' for <script>...js code...</script>
* @return string - when $immediate=true the tag will be printed, "" otherwise
*/
public function js($files, $immediate=false, $how='link')
/**
* Processes/minify/combines queued files of the requested type.
* @param string type - 'js' or 'css'. This should be the end result type
* @param string how - 'link' for <script src="">, 'async' for <script src="" async>, 'embed' for <script>...js code...</script>
* @param array files - string name of a file or array containing multiple string of files
* @return string - the <script> or <link>
*/
$this->Shrink->fetch($type, $how='link')
// in your AppController.php
$helpers = array('Form','Html',
'Shrink.Shrink'=>array(
'url'=>'http://assets.yourdomain.com'
)
);
public $settings = array(
'js'=>array(
'path'=>'js/', // folder to find src js files
'cachePath'=>'js/', // folder to create cache files
'minifier'=>'jsmin' // minifier to minify, false to leave as is
),
'css'=>array(
'path'=>'css/', // folder to find src css files
'cachePath'=>'css/', // folder to create cache files
'minifier'=>'cssmin', // minifier name to minify, false to leave as is
'charset'=>'utf-8' // charset to use
),
'url'=>'', // url without ending /, incase you access from another domain
'prefix'=>'shrink_', // prefix the beginning of cache files
'debugLevel'=>1 // compared against Core.debug, eq will recompile, > will not minify
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.