how can in the yii2 use cdn server ?

i want files of project from server cdn load .

how can in yii doing it ?


You’ve given a bit poor brief of your needs, nevertheless try that

It’s relatively easy.

First, look at an official manual about Assets and Co ->

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

return [

    // ...

    'components' => [

        'assetManager' => [

            'assetMap' => [

                'jquery.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) :

change to :

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: ) 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: