Skip to content

Instantly share code, notes, and snippets.

@azazqadir
Created November 21, 2017 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azazqadir/2be72c03c92cc0a1af332f36d6dc1a75 to your computer and use it in GitHub Desktop.
Save azazqadir/2be72c03c92cc0a1af332f36d6dc1a75 to your computer and use it in GitHub Desktop.
CDN Integration in Yii 2 App. Using CloudwaysCDN to call CSS file from CDN. Full article at: https://www.cloudways.com/blog/cdn-in-yii2/
// ...
'components' => [
   // ...
'cdn' => [
            'class' => '\yii2cdn\Cdn',
            'baseUrl' => defined ('YII2CDN_OFFLINE')
                ? 'http://localhost/yii2/cdn'
                : '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn',
            'basePath' => dirname(__DIR__, 2) . '/cdn',
            'components' => [
                'font-awesome' => [
                    'css' => [
                        [
                            // local version
                            'font-awesome.min.css',
                            // cdn version
                            '@cdn' => '//71265-358070-raikfcquaxqncofqfm.stackpathdns.com/cdn/font-awesome/css/font-awesome.min.css',
                        ]
                    ]
                ]
            ],
        ],
 // ...
],
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment