|
| 1 | +Yii 2 Basic Project Template |
| 2 | +============================ |
| 3 | + |
| 4 | +Yii 2 Basic Project Template is a skeleton [Yii 2](http://www.yiiframework.com/) application best for |
| 5 | +rapidly creating small projects. |
| 6 | + |
| 7 | +The template contains the basic features including user login/logout and a contact page. |
| 8 | +It includes all commonly used configurations that would allow you to focus on adding new |
| 9 | +features to your application. |
| 10 | + |
| 11 | +[](https://packagist.org/packages/yiisoft/yii2-app-basic) |
| 12 | +[](https://packagist.org/packages/yiisoft/yii2-app-basic) |
| 13 | +[](https://travis-ci.org/yiisoft/yii2-app-basic) |
| 14 | + |
| 15 | +DIRECTORY STRUCTURE |
| 16 | +------------------- |
| 17 | + |
| 18 | + assets/ contains assets definition |
| 19 | + commands/ contains console commands (controllers) |
| 20 | + config/ contains application configurations |
| 21 | + controllers/ contains Web controller classes |
| 22 | + mail/ contains view files for e-mails |
| 23 | + models/ contains model classes |
| 24 | + runtime/ contains files generated during runtime |
| 25 | + tests/ contains various tests for the basic application |
| 26 | + vendor/ contains dependent 3rd-party packages |
| 27 | + views/ contains view files for the Web application |
| 28 | + web/ contains the entry script and Web resources |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +REQUIREMENTS |
| 33 | +------------ |
| 34 | + |
| 35 | +The minimum requirement by this project template that your Web server supports PHP 5.4.0. |
| 36 | + |
| 37 | + |
| 38 | +INSTALLATION |
| 39 | +------------ |
| 40 | + |
| 41 | +### Install from an Archive File |
| 42 | + |
| 43 | +Extract the archive file downloaded from [yiiframework.com](http://www.yiiframework.com/download/) to |
| 44 | +a directory named `basic` that is directly under the Web root. |
| 45 | + |
| 46 | +Set cookie validation key in `config/web.php` file to some random secret string: |
| 47 | + |
| 48 | +```php |
| 49 | +'request' => [ |
| 50 | + // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation |
| 51 | + 'cookieValidationKey' => '<secret random string goes here>', |
| 52 | +], |
| 53 | +``` |
| 54 | + |
| 55 | +You can then access the application through the following URL: |
| 56 | + |
| 57 | +~~~ |
| 58 | +http://localhost/basic/web/ |
| 59 | +~~~ |
| 60 | + |
| 61 | + |
| 62 | +### Install via Composer |
| 63 | + |
| 64 | +If you do not have [Composer](http://getcomposer.org/), you may install it by following the instructions |
| 65 | +at [getcomposer.org](http://getcomposer.org/doc/00-intro.md#installation-nix). |
| 66 | + |
| 67 | +You can then install this project template using the following command: |
| 68 | + |
| 69 | +~~~ |
| 70 | +php composer.phar global require "fxp/composer-asset-plugin:~1.0.0" |
| 71 | +php composer.phar create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic |
| 72 | +~~~ |
| 73 | + |
| 74 | +Now you should be able to access the application through the following URL, assuming `basic` is the directory |
| 75 | +directly under the Web root. |
| 76 | + |
| 77 | +~~~ |
| 78 | +http://localhost/basic/web/ |
| 79 | +~~~ |
| 80 | + |
| 81 | + |
| 82 | +CONFIGURATION |
| 83 | +------------- |
| 84 | + |
| 85 | +### Database |
| 86 | + |
| 87 | +Edit the file `config/db.php` with real data, for example: |
| 88 | + |
| 89 | +```php |
| 90 | +return [ |
| 91 | + 'class' => 'yii\db\Connection', |
| 92 | + 'dsn' => 'mysql:host=localhost;dbname=yii2basic', |
| 93 | + 'username' => 'root', |
| 94 | + 'password' => '1234', |
| 95 | + 'charset' => 'utf8', |
| 96 | +]; |
| 97 | +``` |
| 98 | + |
| 99 | +**NOTE:** Yii won't create the database for you, this has to be done manually before you can access it. |
| 100 | + |
| 101 | +Also check and edit the other files in the `config/` directory to customize your application. |
0 commit comments