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>
9 Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for
10 rapidly creating small projects.
12 The template contains the basic features including user login/logout and a contact page.
13 It includes all commonly used configurations that would allow you to focus on adding new
14 features to your application.
16 [![Latest Stable Version](https://img.shields.io/packagist/v/yiisoft/yii2-app-basic.svg)](https://packagist.org/packages/yiisoft/yii2-app-basic)
17 [![Total Downloads](https://img.shields.io/packagist/dt/yiisoft/yii2-app-basic.svg)](https://packagist.org/packages/yiisoft/yii2-app-basic)
18 [![Build Status](https://travis-ci.com/yiisoft/yii2-app-basic.svg?branch=master)](https://travis-ci.com/yiisoft/yii2-app-basic)
23 assets/ contains assets definition
24 commands/ contains console commands (controllers)
25 config/ contains application configurations
26 controllers/ contains Web controller classes
27 mail/ contains view files for e-mails
28 models/ contains model classes
29 runtime/ contains files generated during runtime
30 tests/ contains various tests for the basic application
31 vendor/ contains dependent 3rd-party packages
32 views/ contains view files for the Web application
33 web/ contains the entry script and Web resources
40 The minimum requirement by this project template that your Web server supports PHP 5.6.0.
46 ### Install via Composer
48 If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions
49 at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix).
51 You can then install this project template using the following command:
54 composer create-project --prefer-dist yiisoft/yii2-app-basic basic
57 Now you should be able to access the application through the following URL, assuming `basic` is the directory
58 directly under the Web root.
61 http://localhost/basic/web/
64 ### Install from an Archive File
66 Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to
67 a directory named `basic` that is directly under the Web root.
69 Set cookie validation key in `config/web.php` file to some random secret string:
73 // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
74 'cookieValidationKey' => '<secret random string goes here>',
78 You can then access the application through the following URL:
81 http://localhost/basic/web/
85 ### Install with Docker
87 Update your vendor packages
89 docker-compose run --rm php composer update --prefer-dist
91 Run the installation triggers (creating cookie validation code)
93 docker-compose run --rm php composer install
99 You can then access the application through the following URL:
101 http://127.0.0.1:8000
104 - Minimum required Docker engine version `17.04` for development (see [Performance tuning for volume mounts](https://docs.docker.com/docker-for-mac/osxfs-caching/))
105 - The default configuration uses a host-volume in your home directory `.docker-composer` for composer caches
113 Edit the file `config/db.php` with real data, for example:
117 'class' => 'yii\db\Connection',
118 'dsn' => 'mysql:host=localhost;dbname=yii2basic',
119 'username' => 'root',
120 'password' => '1234',
126 - Yii won't create the database for you, this has to be done manually before you can access it.
127 - Check and edit the other files in the `config/` directory to customize your application as required.
128 - Refer to the README in the `tests` directory for information specific to basic application tests.
134 Tests are located in `tests` directory. They are developed with [Codeception PHP Testing Framework](http://codeception.com/).
135 By default there are 3 test suites:
141 Tests can be executed by running
144 vendor/bin/codecept run
147 The command above will execute unit and functional tests. Unit tests are testing the system components, while functional
148 tests are for testing user interaction. Acceptance tests are disabled by default as they require additional setup since
149 they perform testing in real browser.
152 ### Running acceptance tests
154 To execute acceptance tests do the following:
156 1. Rename `tests/acceptance.suite.yml.example` to `tests/acceptance.suite.yml` to enable suite configuration
158 2. Replace `codeception/base` package in `composer.json` with `codeception/codeception` to install full featured
159 version of Codeception
161 3. Update dependencies with Composer
167 4. Download [Selenium Server](http://www.seleniumhq.org/download/) and launch it:
170 java -jar ~/selenium-server-standalone-x.xx.x.jar
173 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:
177 java -jar -Dwebdriver.gecko.driver=~/geckodriver ~/selenium-server-standalone-3.xx.x.jar
180 java -jar -Dwebdriver.chrome.driver=~/chromedriver ~/selenium-server-standalone-3.xx.x.jar
183 As an alternative way you can use already configured Docker container with older versions of Selenium and Firefox:
186 docker run --net=host selenium/standalone-firefox:2.53.0
189 5. (Optional) Create `yii2_basic_tests` database and update it by applying migrations if you have them.
192 tests/bin/yii migrate
195 The database configuration can be found at `config/test_db.php`.
204 7. Now you can run all available tests
207 # run all available tests
208 vendor/bin/codecept run
210 # run acceptance tests
211 vendor/bin/codecept run acceptance
213 # run only unit and functional tests
214 vendor/bin/codecept run unit,functional
217 ### Code coverage support
219 By default, code coverage is disabled in `codeception.yml` configuration file, you should uncomment needed rows to be able
220 to collect code coverage. You can run your tests and collect coverage with the following command:
223 #collect coverage for all tests
224 vendor/bin/codecept run -- --coverage-html --coverage-xml
226 #collect coverage only for unit tests
227 vendor/bin/codecept run unit -- --coverage-html --coverage-xml
229 #collect coverage for unit and functional tests
230 vendor/bin/codecept run functional,unit -- --coverage-html --coverage-xml
233 You can see code coverage output under the `tests/_output` directory.