Yii 2.0 Medianova CDN Integration
Yii is an open source, object-managed and component-based MVC structure, a PHP web application framework. Yii released the first version in 2006, 2.0 version was released in 2013.
Follow the steps below to integrate Yii 2.0 with Medianova CDN.
- Install the required extension with the aid of “Composer”. Run thecomposer.phar require –prefer-dist blacksmoke26/yii2cdn “*” or add “blacksmoke26/yii2cdn”: “*” to the require section of your composer.json file
- Create the property called “cdn” under the root folder
- Open the (@app/config/web.php) file on the terminal. And then add a property called “cdn” under the “Component” section with the aid of below the code
// ... 'components' => [ // ... 'cdn' => [ 'class' => '\yii2cdn\Cdn', 'baseUrl' => '/cdn', 'basePath' => dirname(dirname(__DIR__)) . '/cdn', 'components' => [ 'style' => [ 'css' => [ [ 'css/style.css', // offline '@cdn' => 'https://yourwebsite.mncdn.com/css/style.css', // online version ] ] ] ], ], // ... ], // ...
- Open any view file and paste the following line
//... Yii::$app->cdn->get('style')->register(); //...
- Check your HTML source code for be sure rewritten asset URL with making the CDN URL instead of Origin