README.md 1.38 KB
Newer Older
1 2
Yii 2 Composer Installer
========================
3

4 5
This is the composer installer for Yii 2 extensions. It implements a new composer package type named `yii2-extension`,
which should be used by all Yii 2 extensions if they are distributed as composer packages.
6

7

8 9
Usage
-----
10

11 12
To use Yii 2 composer installer, simply set `type` to be `yii2-extension` in your `composer.json`,
like the following:
13

14 15 16 17 18 19 20 21
```json
{
	"type": "yii2-extension",
	"require": {
		"yiisoft/yii2": "*"
	},
	...
}
Alexander Makarov committed
22
```
23

Qiang Xue committed
24
You may specify a bootstrap class in the `extra` section. The `init()` method of the class will be executed each time
25 26 27 28 29 30 31 32 33 34 35
the Yii 2 application is responding to a request. For example,

```json
{
	"type": "yii2-extension",
	...,
	"extra": {
		"bootstrap": "yii\\jui\\Extension"
	}
}
```
36

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
The `Installer` class also implements a static method `setPermission()` that can be called after
a Yii 2 projected is installed, through the `post-create-project-cmd` composer script.
The method will set specified directories or files to be writable or executable, depending on
the corresponding parameters set in the `extra` section of the `composer.json` file.
For example,

```json
{
	"name": "yiisoft/yii2-app-basic",
	"type": "project",
	...
	"scripts": {
		"post-create-project-cmd": [
			"yii\\composer\\Installer::setPermission"
		]
	},
	"extra": {
		"writable": [
			"runtime",
			"web/assets"
		],
		"executable": [
			"yii"
		]
	}
}
```