2017 © Pedro Peláez
 

yii2-extension yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

image

blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  • Sunday, July 22, 2018
  • by junaidatari
  • Repository
  • 4 Watchers
  • 12 Stars
  • 391 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 1 Open issues
  • 11 Versions
  • 11 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version License GitHub issues GitHub forks GitHub stars Docs Twitter, (*1)

yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs), (*2)

Production Ready: Used in several real projects is enough to prove its stability., (*3)

Minimum requirements: PHP 7.0+ / Yii2 Framework 2.0.12+, (*4)

Bugs / Feature Request?: Create your issue here., (*5)

Resources

Installation

The preferred way to install this extension is through composer., (*6)

Either run, (*7)

composer require --prefer-dist blacksmoke26/yii2cdn "*"

or add, (*8)

"blacksmoke26/yii2cdn": "*"

to the require section of your composer.json file., (*9)

Usage

Info: This tutorial will demonstrate how to use FancyBox3 library in a production (online/CDN) or development (local/offline) environment., (*10)

#### I. Installing a library

  1. Create a cdn directory under the /root/web folder.
  2. Install or download FancyBox3 library under cdn directory.
    • Path should be /root/web/cdn/jquery-fancybox.
    • CDN URLs: https://cdnjs.com/libraries/fancybox/3.3.5

#### II. Add a component

  1. Open @app/config/main.php in your code editor.
  2. Add a new property cdn under components section like the following code:
// ...
'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
          ],
        ],
      ],
    ],
  ],
  // ...
],
// ...

#### III. Registering assets

  1. Open any view file and paste the following line:
//...
Yii::$app->cdn->get('jquery-fancybox')->register();
//...

IV. Final moment

  1. Browse the action url in your browser and check the view souce.

Now it's time to play around, See ya!, (*11)

The Versions

22/07 2018

dev-master

9999999-dev https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

22/07 2018

1.0.0

1.0.0.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

04/01 2018

0.2.4

0.2.4.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

25/08 2016

0.2.3

0.2.3.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

24/08 2016

0.2.2

0.2.2.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

24/08 2016

0.2.1

0.2.1.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

24/08 2016

0.2.0

0.2.0.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

19/08 2016

0.1.4

0.1.4.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

19/08 2016

0.1.3

0.1.3.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

09/04 2016

0.1.1

0.1.1.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets

09/04 2016

0.1.0

0.1.0.0 https://github.com/blacksmoke26/yii2cdn

A Yii Framework 2 component for using assets in different environments (Local/CDNs)

  Sources   Download

Apache-2.0

The Requires

 

extension yii2 cdn assets