You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.4 KiB
64 lines
1.4 KiB
11 years ago
|
Yii 2 Composer Installer
|
||
|
========================
|
||
12 years ago
|
|
||
11 years ago
|
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.
|
||
12 years ago
|
|
||
11 years ago
|
|
||
11 years ago
|
Usage
|
||
|
-----
|
||
12 years ago
|
|
||
11 years ago
|
To use Yii 2 composer installer, simply set `type` to be `yii2-extension` in your `composer.json`,
|
||
|
like the following:
|
||
12 years ago
|
|
||
11 years ago
|
```json
|
||
|
{
|
||
|
"type": "yii2-extension",
|
||
|
"require": {
|
||
|
"yiisoft/yii2": "*"
|
||
|
},
|
||
|
...
|
||
|
}
|
||
11 years ago
|
```
|
||
11 years ago
|
|
||
11 years ago
|
You may specify a bootstrap class in the `extra` section. The `init()` method of the class will be executed each time
|
||
11 years ago
|
the Yii 2 application is responding to a request. For example,
|
||
|
|
||
|
```json
|
||
|
{
|
||
|
"type": "yii2-extension",
|
||
|
...,
|
||
|
"extra": {
|
||
|
"bootstrap": "yii\\jui\\Extension"
|
||
|
}
|
||
|
}
|
||
|
```
|
||
12 years ago
|
|
||
11 years ago
|
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"
|
||
|
]
|
||
|
}
|
||
|
}
|
||
|
```
|