{"id":25194126,"url":"https://github.com/blacksmoke26/yii2cdn","last_synced_at":"2025-05-08T00:52:33.780Z","repository":{"id":56950991,"uuid":"55599912","full_name":"blacksmoke26/yii2cdn","owner":"blacksmoke26","description":"A Yii Framework 2 component for using assets in different environments (Local/CDNs)","archived":false,"fork":false,"pushed_at":"2020-12-05T11:07:58.000Z","size":406,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-08T00:52:25.921Z","etag":null,"topics":["assets","cdn","components","management","php","yii2"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blacksmoke26.png","metadata":{"files":{"readme":"README.md","changelog":"history.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-06T11:22:52.000Z","updated_at":"2022-07-26T10:51:03.000Z","dependencies_parsed_at":"2022-08-21T09:20:29.550Z","dependency_job_id":null,"html_url":"https://github.com/blacksmoke26/yii2cdn","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blacksmoke26%2Fyii2cdn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blacksmoke26%2Fyii2cdn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blacksmoke26%2Fyii2cdn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blacksmoke26%2Fyii2cdn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blacksmoke26","download_url":"https://codeload.github.com/blacksmoke26/yii2cdn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978724,"owners_count":21834914,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assets","cdn","components","management","php","yii2"],"created_at":"2025-02-09T23:52:31.307Z","updated_at":"2025-05-08T00:52:33.757Z","avatar_url":"https://github.com/blacksmoke26.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/blacksmoke26/yii2cdn/v/stable)](https://packagist.org/packages/blacksmoke26/yii2cdn) [![Total Downloads](https://poser.pugx.org/blacksmoke26/yii2cdn/downloads)](https://packagist.org/packages/blacksmoke26/yii2cdn) [![Latest Unstable Version](https://poser.pugx.org/blacksmoke26/yii2cdn/v/unstable)](https://packagist.org/packages/blacksmoke26/yii2cdn) [![License](https://poser.pugx.org/blacksmoke26/yii2cdn/license)](https://packagist.org/packages/blacksmoke26/yii2cdn)\n[![GitHub issues](https://img.shields.io/github/issues/blacksmoke26/yii2cdn.svg)](https://github.com/blacksmoke26/yii2cdn/issues)\n[![GitHub forks](https://img.shields.io/github/forks/blacksmoke26/yii2cdn.svg)](https://github.com/blacksmoke26/yii2cdn/network)\n[![GitHub stars](https://img.shields.io/github/stars/blacksmoke26/yii2cdn.svg)](https://github.com/blacksmoke26/yii2cdn/stargazers)\n[![Docs](https://img.shields.io/badge/docs-15%25-yellow.svg)](https://github.com/blacksmoke26/yii2cdn/wiki)\n[![Twitter](https://img.shields.io/twitter/url/https/github.com/blacksmoke26/yii2cdn.svg?style=social)](https://twitter.com/intent/tweet?text=Yii2cdn+extension:\u0026url=https://github.com/blacksmoke26/yii2cdn)\n\n# yii2cdn\n\nA Yii Framework 2 component for using assets in different environments (Local/CDNs)\n\n**Production Ready**: Used in several real projects is enough to prove its stability.\n\n**Minimum requirements:** PHP 7.0+ / Yii2 Framework 2.0.12+\n\n**Bugs / Feature Request?:** Create your [issue here](https://github.com/blacksmoke26/yii2cdn/issues).\n\n## Resources\n\n* **Wiki**: [https://github.com/blacksmoke26/yii2cdn/wiki](https://github.com/blacksmoke26/yii2cdn/wiki)\n* **Class Reference**: [http://blacksmoke26.github.io/yii2cdn/api/](http://blacksmoke26.github.io/yii2cdn/api/)\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\ncomposer require --prefer-dist blacksmoke26/yii2cdn \"*\"\n```\n\nor add\n\n```\n\"blacksmoke26/yii2cdn\": \"*\"\n```\n\nto the require section of your `composer.json` file.\n\n\n## Usage\n\n**Info:** *This tutorial will demonstrate how to use [`FancyBox3`](http://fancyapps.com/fancybox/3/) library in a \u003ccode\u003eproduction\u003c/code\u003e (online/CDN) or \u003ccode\u003edevelopment\u003c/code\u003e (local/offline) environment.*\n\n#### I. Installing a library\n--------------------------\n1. Create a \u003ccode\u003ecdn\u003c/code\u003e directory under the `/root/web` folder.\n2. Install or download [`FancyBox3`](http://fancyapps.com/fancybox/3/) library under \u003ccode\u003ecdn\u003c/code\u003e directory.\n  * Path should be `/root/web/cdn/jquery-fancybox`.\n  * CDN URLs: https://cdnjs.com/libraries/fancybox/3.3.5\n\n#### II. Add a component\n---------------------\n1. Open `@app/config/main.php` in your code editor.\n2. Add a new property `cdn` under `components` section like the following code:\n\n```php\n// ...\n'components' =\u003e [\n  // ...\n  'cdn' =\u003e [\n    'class' =\u003e '\\yii2cdn\\Cdn',\n      'baseUrl' =\u003e '/cdn',\n      'basePath' =\u003e dirname(__DIR__) . '/web/cdn',\n      'components' =\u003e [\n      'jquery-fancybox' =\u003e [\n        'css' =\u003e [\n          '@attributes' =\u003e [\n            'noNameInPathUrls' =\u003e true, // Hide /css in urls\n          ],\n          [\n            'dist/jquery.fancybox.css', // offline version\n            '@cdn' =\u003e '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.css', // online version\n          ],\n        ],\n        'js' =\u003e [\n          '@attributes' =\u003e [\n            'noNameInPathUrls' =\u003e true, // Hide /js in urls\n          ],\n          [\n            'dist/jquery.fancybox.js', // offline version\n            '@cdn' =\u003e '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.3.5/jquery.fancybox.min.js', // online version\n          ],\n        ],\n      ],\n    ],\n  ],\n  // ...\n],\n// ...\n```\n\n#### III. Registering assets\n-------------------\n1. Open any view file and paste the following line:\n\n```php\n//...\nYii::$app-\u003ecdn-\u003eget('jquery-fancybox')-\u003eregister();\n//...\n```\n\n#### IV. Final moment\n1. Browse the action url in your browser and check the view souce.\n\n\u003e Now it's time to play around, See ya!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblacksmoke26%2Fyii2cdn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblacksmoke26%2Fyii2cdn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblacksmoke26%2Fyii2cdn/lists"}