-
Notifications
You must be signed in to change notification settings - Fork 2
How to use Yii2cdn
Junaid Atari edited this page Aug 24, 2016
·
3 revisions
Info: This tutorial will demonstrate how to use Font-Awesome library in a production (online/CDN) or development (local/offline) environment.
- Create a
cdndirectory under your root folder. - Install or download
FortAwesome/Font-Awesomelibrary undercdndirectory.
- Path should be
/cdn/font-awesome.
- Open
@app/config/main.phpin your code editor. - Add a new propery
cdnundercomponentssection like following code:
// ...
'components' => [
// ...
'cdn' => [
'class' => '\yii2cdn\Cdn',
'baseUrl' => '/cdn',
'basePath' => dirname(dirname(__DIR__)) . '/cdn',
'components' => [
'font-awesome' => [
'css' => [
[
'font-awesome.min.css', // offline version
'@cdn' => '//cdnjs.cloudflare.com/ajax/libs/font-awesome/'
. '4.5.0/css/font-awesome.min.css', // online version
]
]
]
],
],
// ...
],
// ...- Open any view file and paste the following line:
//...
Yii::$app->cdn->get('font-awesome')->register();
//...- Browse the action url in your browser and check the view souce.
Now it's time to play around, See ya!
Copyright (c) 2016 Junaid Atari and it's contributes.