PHP code example of blacksmoke26 / yii2cdn

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

    

blacksmoke26 / yii2cdn example snippets


// ...
'components' => [
  // ...
  'cdn' => [
    'class' => '\yii2cdn\Cdn',
      'baseUrl' => '/cdn',
      'basePath' => dirname(__DIR__) . '/web/cdn',
      'components' => [
      'jquery-fancybox' => [
        'css' => [
          '@attributes' => [
            'noNameInPathUrls' => true, // Hide /css in urls
          ],
          [
            'dist/jquery.fancybox.css', // offline version
            '@cdn' => '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css', // online version
          ],
        ],
        'js' => [
          '@attributes' => [
            'noNameInPathUrls' => true, // Hide /js in urls
          ],
          [
            'dist/jquery.fancybox.js', // offline version
            '@cdn' => '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js', // online version
          ],
        ],
      ],
    ],
  ],
  // ...
],
// ...

//...
Yii::$app->cdn->get('jquery-fancybox')->register();
//...