githubjeka / rest-yii2
Yii 2 Rest Api Template
Installs: 1 834
Dependents: 0
Suggesters: 0
Security: 0
Stars: 159
Watchers: 27
Forks: 76
Open Issues: 8
Type:project
Requires
- php: >=5.4.0
- yiisoft/yii2: ~2.0.6
- yiisoft/yii2-bootstrap: ~2.0.0
- yiisoft/yii2-swiftmailer: ~2.0.0 || ~2.1.0
Requires (Dev)
- codeception/base: ^2.2.3
- codeception/verify: ~0.3.1
- yiisoft/yii2-debug: ~2.0.0
- yiisoft/yii2-faker: ~2.0.0
- yiisoft/yii2-gii: ~2.0.0
This package is auto-updated.
Last update: 2024-11-19 18:00:31 UTC
README
INSTALLATION
Install via Composer
If you do not have Composer, you may install it by following the instructions at getcomposer.org.
You can then install the application using the following commands:
composer global require "fxp/composer-asset-plugin:~1.0.0"
composer create-project --prefer-dist -s dev "githubjeka/rest-yii2" .
GETTING STARTED
After you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all.
- Run command
php init --env=Development
to initialize the application with a specific environment. - Create a new database and adjust the
components['db']
configuration incommon/config/main-local.php
accordingly. - Apply migrations with console command
php yii migrate
. This will create tables needed for the application to work. - Set document roots of your Web server:
for rest /path/to/yii-application/rest/web/
and using the URL http://localhost/
for backend /path/to/yii-application/backend/web/
and using the URL http://backend-localhost/
Use demo/demo
to login into the application on http://localhost/v1/user/login. See
/rest/config/main.php
for more info by URL
URL RULE
API available:
// version 1 OPTIONS /index.php?r=v1/user/login POST /index.php?r=v1/user/login OPTIONS /index.php?r=v1/posts GET /index.php?r=v1/posts GET /index.php?r=v1/posts/ID POST /index.php?r=v1/posts PUT /index.php?r=v1/posts/ID DELETE /index.php?r=v1/posts/ID OPTIONS /index.php?r=v1/comments GET /index.php?r=v1/comments GET /index.php?r=v1/comments/ID POST /index.php?r=v1/comments PUT /index.php?r=v1/comments/ID DELETE /index.php?r=v1/comments/ID //version 2 OPTIONS /index.php?r=v2/user/login POST /index.php?r=v2/user/login
You can hide index.php
from URL. For that see server.md