项目作者: BrazhnikovV

项目描述 :
php yii2 rest api
高级语言: PHP
项目地址: git://github.com/BrazhnikovV/shop-rest-api.git
创建时间: 2019-03-06T13:48:39Z
项目社区:https://github.com/BrazhnikovV/shop-rest-api

开源协议:Other

下载


TEST REST API APPLICATION ON Yii2

Build Status

Demo Server

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:

  1. composer global require "fxp/composer-asset-plugin:~1.0.0"
  2. 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 in common/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

See rest/config/main.php

API available:

  1. // version 1
  2. OPTIONS /index.php?r=v1/user/login
  3. POST /index.php?r=v1/user/login
  4. OPTIONS /index.php?r=v1/posts
  5. GET /index.php?r=v1/posts
  6. GET /index.php?r=v1/posts/ID
  7. POST /index.php?r=v1/posts
  8. PUT /index.php?r=v1/posts/ID
  9. DELETE /index.php?r=v1/posts/ID
  10. OPTIONS /index.php?r=v1/comments
  11. GET /index.php?r=v1/comments
  12. GET /index.php?r=v1/comments/ID
  13. POST /index.php?r=v1/comments
  14. PUT /index.php?r=v1/comments/ID
  15. DELETE /index.php?r=v1/comments/ID
  16. //version 2
  17. OPTIONS /index.php?r=v2/user/login
  18. POST /index.php?r=v2/user/login

You can hide index.php from URL. For that see server.md

ADDITIONALLY

See client on AngularJS