Skip to content

Config Structure

Junaid Atari edited this page Aug 23, 2016 · 5 revisions

Structure

The base structure of components/configs (config file) is described in the following section:

[
	'component-id1' => [
		'js' => [
			'path/to/file1.js',
			[
				'@url(www.domain.com/)file2.js'
			]
		],
		'css' => []
	],
	'component-id2' => [
		'@src' => 'path/to',
         // Component attributes (optional)
        '@attributes' => [
          'name' => 'value',
          // ...
        ],
		'js' => [
             // Section attributes (optional)
            '@attributes' => [
              'name' => 'value',
              // ...
            ],
			'@baseUrl/file1.js',
			[
				'file2.js', '@id'=>'xyz', '@cdn' =>'//cdn-url.com/file-1x.min.js'
			],
			'@baseUrl/file3.js',
			'@baseUrl/file4.js',
		],
		'css' => []
	],
	'component-id3' => [
		'@baseUrl' => '/url3/to',
		'css' => [
			'to/file1.js',
			'/to/file2.css',
			[
				'file3.css', '@cdn' =>'//cdn-url.com/file-x.x.min.css'
			]
		]
	],
	'component-id4' => [
		'@src' => 'path4/to',
		'@offline' => true,
		'@offlineSections' => ['css'],
		'@baseUrl' => '/url4/to',
		'js' => [
			'@thisComponentUrl/xyz.js',
			'@thisSectionUrl/bundle.js',
			['@baseUrl/file4-js1.js', '@id'=>'fixl'],
			[
				'file4-js2.js', '@offline' => true, '@id'=>'xyz', '@options'=>['x'=>'x'], '@cdn' =>'//cdn-url.com/file-4-js2.min.js',
                // File attributes without starting with @ (optional)
                'fooBar' => 'dummy'
			],
			'@baseUrl/file4-js3.js',
			'@baseUrl/file4-js4.js',
		],
		'css' => [
			'@componentUrl(component-id2)/to/file1.js',
			'/to/file2.css',
			[
				'file3.css', '@id'=>'file3.css', '@cdn' =>'//cdn-url.com/to/file-x.x.min.css'
			],
			'@componentFile(component-id2/js/xyz)',
		]
	]
]

Usage

There are two different ways of using component configuration:

  1. Add in Cdn's component property.
  1. Create a cdn-config file and paste in it.

Note: the red links below are pages yet to be created. Feel free to add them!

Overview documents

  • README: distributed with yii2cdn, contains a quick overview of yii2cdn's functionality, an example, and the license.
  • REFERENCE: Containing incomplete api class reference.

Quick Start

Configuration

Tutorials

Clone this wiki locally