rockielin/yii2-basic-restful-api-template

Simple web api with Yii2 basic template

dev-master 2016-07-17 18:16 UTC

This package is auto-updated.

Last update: 2024-04-06 17:13:02 UTC


README

Simple web api

Basic web api using POST or GET method with json response

Latest Stable Version Total Downloads

INSTALLATION

You can choose to install the application using one of the following methods.

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 command:

php composer.phar global require "fxp/composer-asset-plugin:~1.1"
php composer.phar create-project --prefer-dist --stability=dev rockielin/yii2-basic-restful-api-template project-name

Enable debug:

create file "develop.me" in /config/

Request:

all request using POST or GET method.

POST parameter validate using in controller:

$this->checkParms(["parm1",
  "parm2",.....]);

Response:

success reqponse format:

{"data":json object,"status":200}

error reqponse format:

{"data":"message","status":status code}

example of error output:

throw new \yii\web\HttpException(401, "authentication failed!");