|
| 1 | +Yii 2 Basic API Template |
| 2 | +=============================== |
| 3 | + |
| 4 | +Yii 2 Basic API Template is a skeleton [Yii 2](http://www.yiiframework.com) application best for rapidly |
| 5 | +creating small API applications. |
| 6 | + |
| 7 | +The template is designed to work in a team development environment. |
| 8 | +It supports deploying the application in different environments. |
| 9 | + |
| 10 | +INSTALLATION |
| 11 | +------------ |
| 12 | + |
| 13 | +## Install via Composer |
| 14 | + |
| 15 | +Run the [Composer](http://getcomposer.org) commands to install: |
| 16 | + |
| 17 | +```bash |
| 18 | +composer global require fxp/composer-asset-plugin ~1.1.1 |
| 19 | +composer create-project --prefer-dist frostealth/yii2-api-basic my-api |
| 20 | +``` |
| 21 | + |
| 22 | +## Preparing application |
| 23 | + |
| 24 | +After you install the application, you have to conduct the following steps to initialize |
| 25 | +the installed application. You only need to do these once for all. |
| 26 | + |
| 27 | +1. Execute the `init` command and select `dev` as environment. |
| 28 | + |
| 29 | + ``` |
| 30 | + php /path/to/my-api/init --env=development |
| 31 | + ``` |
| 32 | + |
| 33 | + Otherwise, in production execute `init` in non-interactive mode. |
| 34 | + |
| 35 | + ``` |
| 36 | + php /path/to/my-api/init --env=production --overwrite=a |
| 37 | + ``` |
| 38 | + |
| 39 | +2. Create a new database and adjust the configuration in `common/config/db-local.php` accordingly. |
| 40 | + |
| 41 | +DIRECTORY STRUCTURE |
| 42 | +------------------- |
| 43 | + |
| 44 | +``` |
| 45 | +commands/ contains console controllers (commands) |
| 46 | +common |
| 47 | + controllers/ contains shared api-specific controllers |
| 48 | + models/ contains shared api-specific model classes |
| 49 | +config/ contains application configurations |
| 50 | +mail/ contains view files for e-mails |
| 51 | +runtime/ contains files generated during runtime |
| 52 | +versions contains api versions as modules |
| 53 | + v1/ |
| 54 | + controllers/ contains version-specific controllers |
| 55 | + models/ contains version-specific model classes |
| 56 | +web/ contains the entry script |
| 57 | +vendor/ contains dependent 3rd-party packages |
| 58 | +environments/ contains environment-based overrides |
| 59 | +``` |
0 commit comments