Skip to content
This repository was archived by the owner on Jan 10, 2022. It is now read-only.

Commit 2a94471

Browse files
committed
README.md restored
1 parent df80a23 commit 2a94471

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

README.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
Install Extension for Yii 2
2+
===========================
3+
4+
This extension provides ability for automated initialization of the project working copy, including local directories and
5+
files creation, running DB migrations and so on.
6+
7+
For license information check the [LICENSE](LICENSE.md)-file.
8+
9+
[![Latest Stable Version](https://poser.pugx.org/yii2tech/install/v/stable.png)](https://packagist.org/packages/yii2tech/install)
10+
[![Total Downloads](https://poser.pugx.org/yii2tech/install/downloads.png)](https://packagist.org/packages/yii2tech/install)
11+
[![Build Status](https://travis-ci.org/yii2tech/install.svg?branch=master)](https://travis-ci.org/yii2tech/install)
12+
13+
14+
Requirements
15+
------------
16+
17+
This extension requires Linux OS.
18+
19+
20+
Installation
21+
------------
22+
23+
The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
24+
25+
Either run
26+
27+
```
28+
php composer.phar require --prefer-dist yii2tech/install
29+
```
30+
31+
or add
32+
33+
```json
34+
"yii2tech/install": "*"
35+
```
36+
37+
to the require section of your composer.json.
38+
39+
If you wish to setup crontab during project installation, you will also need to install [yii2tech/crontab](https://github.com/yii2tech/crontab),
40+
which is not required by default. In order to do so either run
41+
42+
```
43+
php composer.phar require --prefer-dist yii2tech/crontab
44+
```
45+
46+
or add
47+
48+
```json
49+
"yii2tech/crontab": "*"
50+
```
51+
52+
to the require section of your composer.json.
53+
54+
55+
Usage
56+
-----
57+
58+
This extension provides special console controller [[yii2tech\install\InitController]], which allows initialization of the
59+
project working copy. Such initialization includes:
60+
61+
- check if current environment matches project requirements.
62+
- create local directories (the ones, which may be not stored in version control system) and make them write-able.
63+
- create local files, such as configuration files, from templates.
64+
- run extra shell commands, like 'yii migrate' command.
65+
- setup cron jobs.
66+
67+
In order to create an installer, you should create a separated console application entry script. This script should
68+
be absolutely stripped from the local configuration files, database and so on!
69+
See [examples/install.php](examples/install.php) for the example of such script.
70+
71+
Once you have such script you can run installation process, using following command:
72+
73+
```
74+
php install.php init
75+
```
76+
77+
78+
## Working with local files <span id="working-with-local-files"></span>
79+
80+
The most interesting feature introduced by [[yii2tech\install\InitController]] is creating local project files, such as
81+
configuration files, from thier examples in interactive mode.
82+
For each file, which content may vary depending on actual project environment, you should create a template file named in
83+
format `{filename}.sample`. This file should be located under the same directory, where the actual local file should appear.
84+
Inside the template file you can use placeholders in format: `{{placeholderName}}`. For example:
85+
86+
```php
87+
defined('YII_DEBUG') or define('YII_DEBUG', {{yiiDebug}});
88+
defined('YII_ENV') or define('YII_ENV', '{{yiiEnv}}');
89+
90+
return [
91+
'components' => [
92+
'db' => [
93+
'dsn' => 'mysql:host={{dbHost}};dbname={{dbName}}',
94+
'username' => '{{dbUser}}',
95+
'password' => '{{dbPassword}}',
96+
],
97+
],
98+
];
99+
```
100+
101+
While being processed, file templates are parsed, and for all found placeholders user will be asked to enter a value for them.
102+
You can make this process more user-friendly by setting [[yii2tech\install\InitController::localFilePlaceholders]], specifying
103+
hints, type and validation rules. See [[yii2tech\install\LocalFilePlaceholder]] for more details.
104+
105+
106+
## Non interactive installation <span id="non-interactive-installation"></span>
107+
108+
Asking user for particular placeholder value may be not efficient and sometimes not acceptable. You may need to run
109+
project intallation in fully automatic mode without user input, for example after updating source code from version
110+
control system inside automatic project update.
111+
In order to disable any user-interaction, you should use `interactive` option:
112+
113+
```
114+
php install.php init --interactive=0
115+
```
116+
117+
In this mode for all local file placeholders the default values will be taken, but only in case such values are explicitely
118+
defined via [[yii2tech\install\InitController::localFilePlaceholders]]. Because install entry script usually stored under
119+
version control system and local file placeholder values (as well as other installation parameters) may vary depending
120+
on particular environment, [[yii2tech\install\InitController]] instroduce 'config' option. Using this option you may
121+
specify extra configuration file, which should be merged with predefined parameters.
122+
In order to create such configuration file, you can use following:
123+
124+
```
125+
php install.php init/config @app/config/install.php
126+
```
127+
128+
Once you have adjusted created configuration file, you can run installation with it:
129+
130+
```
131+
php install.php init --config=@app/config/install.php --interactive=0
132+
```

0 commit comments

Comments
 (0)