how can in the yii2 use cdn server ?

i want files of project from server cdn load .

how can in yii doing it ?

Hi,

You’ve given a bit poor brief of your needs, nevertheless try that https://yiigist.com/package/frostealth/yii2-aws-s3#?tab=readme

It’s relatively easy.

First, look at an official manual about Assets and Co -> http://www.yiiframework.com/doc-2.0/guide-structure-assets.html

Secondly, you can use, for example, assets mapping, like this:


return [

    // ...

    'components' => [

        'assetManager' => [

            'assetMap' => [

                'jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js',

            ],

        ],

    ],

]; 

Hope, it’ll help you.

have a nice day! :)

thank you.

how files of yii framework on cdn server load ?

for exsample(over link genrated by yii) :


http://site.com/web/assets/7b3a3c7b/yii.gridView.js

change to :


http://cdn.site.com/web/assets/7b3a3c7b/yii.gridView.js

It depends on which CDN you use. Check it’s docs.

If you are having issues in integrating cdn in yii2 app, I would suggest you to use a platform (like this one: https://www.cloudways.com/blog/cdn-in-yii2/ ) where you can integrate cdn much easily. Yii2 has some open source packages that configure CDN services for delivering assets such as CSS and JavaScript files, like blacksmoke26/yii2cdn package. If you have this package installed, create a CDN directory in the root and install the asset in it. Open web.php under config folder and add cdn property under component. Define two version of the files, one for the local and another for the live version. Add code, something like this, in the view:

Yii::$app->cdn->get(‘font-awesome’)->register();