2 <a href="https://github.com/yiisoft" target="_blank">
3 <img src="https://avatars0.githubusercontent.com/u/993323" height="100px">
5 <h1 align="center">Yii 2 Basic Project Template</h1>
10 <p>Перед использованием, необходимо внести изменения в файлы:</p>
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 символа.
18 Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
19 rapidly creating small projects.
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.
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)
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
49 The minimum requirement by this project template that your Web server supports PHP 5.6.0.
55 ### Install via Composer
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).
60 You can then install this project template using the following command:
63 composer create-project --prefer-dist yiisoft/yii2-app-basic basic
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.
70 http://localhost/basic/web/
73 ### Install from an Archive File
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.
78 Set cookie validation key in `config/web.php` file to some random secret string:
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>',
87 You can then access the application through the following URL:
90 http://localhost/basic/web/
94 ### Install with Docker
96 Update your vendor packages
98 docker-compose run --rm php composer update --prefer-dist
100 Run the installation triggers (creating cookie validation code)
102 docker-compose run --rm php composer install
108 You can then access the application through the following URL:
110 http://127.0.0.1:8000
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
122 Edit the file `config/db.php` with real data, for example:
126 'class' => 'yii\db\Connection',
127 'dsn' => 'mysql:host=localhost;dbname=yii2basic',
128 'username' => 'root',
129 'password' => '1234',
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.
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:
150 Tests can be executed by running
153 vendor/bin/codecept run
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.
161 ### Running acceptance tests
163 To execute acceptance tests do the following:
165 1. Rename `tests/acceptance.suite.yml.example` to `tests/acceptance.suite.yml` to enable suite configuration
167 2. Replace `codeception/base` package in `composer.json` with `codeception/codeception` to install full featured
168 version of Codeception
170 3. Update dependencies with Composer
176 4. Download [Selenium Server](http://www.seleniumhq.org/download/) and launch it:
179 java -jar ~/selenium-server-standalone-x.xx.x.jar
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:
186 java -jar -Dwebdriver.gecko.driver=~/geckodriver ~/selenium-server-standalone-3.xx.x.jar
189 java -jar -Dwebdriver.chrome.driver=~/chromedriver ~/selenium-server-standalone-3.xx.x.jar
192 As an alternative way you can use already configured Docker container with older versions of Selenium and Firefox:
195 docker run --net=host selenium/standalone-firefox:2.53.0
198 5. (Optional) Create `yii2_basic_tests` database and update it by applying migrations if you have them.
201 tests/bin/yii migrate
204 The database configuration can be found at `config/test_db.php`.
213 7. Now you can run all available tests
216 # run all available tests
217 vendor/bin/codecept run
219 # run acceptance tests
220 vendor/bin/codecept run acceptance
222 # run only unit and functional tests
223 vendor/bin/codecept run unit,functional
226 ### Code coverage support
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:
232 #collect coverage for all tests
233 vendor/bin/codecept run -- --coverage-html --coverage-xml
235 #collect coverage only for unit tests
236 vendor/bin/codecept run unit -- --coverage-html --coverage-xml
238 #collect coverage for unit and functional tests
239 vendor/bin/codecept run functional,unit -- --coverage-html --coverage-xml
242 You can see code coverage output under the `tests/_output` directory.