OSDN Git Service

Внесение важной информации в README.md перед началом работы с репозиторием
[invent/invent.git] / README.md
1 <p align="center">
2     <a href="https://github.com/yiisoft" target="_blank">
3         <img src="https://avatars0.githubusercontent.com/u/993323" height="100px">
4     </a>
5     <h1 align="center">Yii 2 Basic Project Template</h1>
6     <br>
7 </p>
8
9 <h1>ВНИМАНИЕ!</h1>
10 <p>Перед использованием, необходимо внести изменения в файлы:</p>
11 <ul>
12     <li><code>/config/db.php</code> - указать подключение к базе данных, лоин и пароль</li>
13     <li><code>/config/params.php</code> - указать правильные электронные адреса для администратора и отправителя</li>
14     <li><code>/config/web.php</code> - указать cookieValidationKey 32 символа.
15 </ul>
16
17
18 Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
19 rapidly creating small projects.
20
21 The template contains the basic features including user login/logout and a contact page.
22 It includes all commonly used configurations that would allow you to focus on adding new
23 features to your application.
24
25 [![Latest Stable Version](https://img.shields.io/packagist/v/yiisoft/yii2-app-basic.svg)](https://packagist.org/packages/yiisoft/yii2-app-basic)
26 [![Total Downloads](https://img.shields.io/packagist/dt/yiisoft/yii2-app-basic.svg)](https://packagist.org/packages/yiisoft/yii2-app-basic)
27 [![Build Status](https://travis-ci.com/yiisoft/yii2-app-basic.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-app-basic)
28
29 DIRECTORY STRUCTURE
30 -------------------
31
32       assets/             contains assets definition
33       commands/           contains console commands (controllers)
34       config/             contains application configurations
35       controllers/        contains Web controller classes
36       mail/               contains view files for e-mails
37       models/             contains model classes
38       runtime/            contains files generated during runtime
39       tests/              contains various tests for the basic application
40       vendor/             contains dependent 3rd-party packages
41       views/              contains view files for the Web application
42       web/                contains the entry script and Web resources
43
44
45
46 REQUIREMENTS
47 ------------
48
49 The minimum requirement by this project template that your Web server supports PHP 5.6.0.
50
51
52 INSTALLATION
53 ------------
54
55 ### Install via Composer
56
57 If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions
58 at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).
59
60 You can then install this project template using the following command:
61
62 ~~~
63 composer create-project --prefer-dist yiisoft/yii2-app-basic basic
64 ~~~
65
66 Now you should be able to access the application through the following URL, assuming `basic` is the directory
67 directly under the Web root.
68
69 ~~~
70 http://localhost/basic/web/
71 ~~~
72
73 ### Install from an Archive File
74
75 Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to
76 a directory named `basic` that is directly under the Web root.
77
78 Set cookie validation key in `config/web.php` file to some random secret string:
79
80 ```php
81 'request' => [
82     // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
83     'cookieValidationKey' => '<secret random string goes here>',
84 ],
85 ```
86
87 You can then access the application through the following URL:
88
89 ~~~
90 http://localhost/basic/web/
91 ~~~
92
93
94 ### Install with Docker
95
96 Update your vendor packages
97
98     docker-compose run --rm php composer update --prefer-dist
99     
100 Run the installation triggers (creating cookie validation code)
101
102     docker-compose run --rm php composer install    
103     
104 Start the container
105
106     docker-compose up -d
107     
108 You can then access the application through the following URL:
109
110     http://127.0.0.1:8000
111
112 **NOTES:** 
113 - Minimum required Docker engine version `17.04` for development (see [Performance tuning for volume mounts](https://docs.docker.com/docker-for-mac/osxfs-caching/))
114 - The default configuration uses a host-volume in your home directory `.docker-composer` for composer caches
115
116
117 CONFIGURATION
118 -------------
119
120 ### Database
121
122 Edit the file `config/db.php` with real data, for example:
123
124 ```php
125 return [
126     'class' => 'yii\db\Connection',
127     'dsn' => 'mysql:host=localhost;dbname=yii2basic',
128     'username' => 'root',
129     'password' => '1234',
130     'charset' => 'utf8',
131 ];
132 ```
133
134 **NOTES:**
135 - Yii won't create the database for you, this has to be done manually before you can access it.
136 - Check and edit the other files in the `config/` directory to customize your application as required.
137 - Refer to the README in the `tests` directory for information specific to basic application tests.
138
139
140 TESTING
141 -------
142
143 Tests are located in `tests` directory. They are developed with [Codeception PHP Testing Framework](http://codeception.com/).
144 By default there are 3 test suites:
145
146 - `unit`
147 - `functional`
148 - `acceptance`
149
150 Tests can be executed by running
151
152 ```
153 vendor/bin/codecept run
154 ```
155
156 The command above will execute unit and functional tests. Unit tests are testing the system components, while functional
157 tests are for testing user interaction. Acceptance tests are disabled by default as they require additional setup since
158 they perform testing in real browser. 
159
160
161 ### Running  acceptance tests
162
163 To execute acceptance tests do the following:  
164
165 1. Rename `tests/acceptance.suite.yml.example` to `tests/acceptance.suite.yml` to enable suite configuration
166
167 2. Replace `codeception/base` package in `composer.json` with `codeception/codeception` to install full featured
168    version of Codeception
169
170 3. Update dependencies with Composer 
171
172     ```
173     composer update  
174     ```
175
176 4. Download [Selenium Server](http://www.seleniumhq.org/download/) and launch it:
177
178     ```
179     java -jar ~/selenium-server-standalone-x.xx.x.jar
180     ```
181
182     In case of using Selenium Server 3.0 with Firefox browser since v48 or Google Chrome since v53 you must download [GeckoDriver](https://github.com/mozilla/geckodriver/releases) or [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/downloads) and launch Selenium with it:
183
184     ```
185     # for Firefox
186     java -jar -Dwebdriver.gecko.driver=~/geckodriver ~/selenium-server-standalone-3.xx.x.jar
187     
188     # for Google Chrome
189     java -jar -Dwebdriver.chrome.driver=~/chromedriver ~/selenium-server-standalone-3.xx.x.jar
190     ``` 
191     
192     As an alternative way you can use already configured Docker container with older versions of Selenium and Firefox:
193     
194     ```
195     docker run --net=host selenium/standalone-firefox:2.53.0
196     ```
197
198 5. (Optional) Create `yii2_basic_tests` database and update it by applying migrations if you have them.
199
200    ```
201    tests/bin/yii migrate
202    ```
203
204    The database configuration can be found at `config/test_db.php`.
205
206
207 6. Start web server:
208
209     ```
210     tests/bin/yii serve
211     ```
212
213 7. Now you can run all available tests
214
215    ```
216    # run all available tests
217    vendor/bin/codecept run
218
219    # run acceptance tests
220    vendor/bin/codecept run acceptance
221
222    # run only unit and functional tests
223    vendor/bin/codecept run unit,functional
224    ```
225
226 ### Code coverage support
227
228 By default, code coverage is disabled in `codeception.yml` configuration file, you should uncomment needed rows to be able
229 to collect code coverage. You can run your tests and collect coverage with the following command:
230
231 ```
232 #collect coverage for all tests
233 vendor/bin/codecept run -- --coverage-html --coverage-xml
234
235 #collect coverage only for unit tests
236 vendor/bin/codecept run unit -- --coverage-html --coverage-xml
237
238 #collect coverage for unit and functional tests
239 vendor/bin/codecept run functional,unit -- --coverage-html --coverage-xml
240 ```
241
242 You can see code coverage output under the `tests/_output` directory.