Fork me on GitHub

2.1 Tutorial

In this chapter, we wil explore how to enjoy developing an API in the shortest time.

Here we go!

2.2 Write an API

Let's start from "Hello World!". Put the follow code inside file ./Demo/Api/Welcome.php.

<?php

class Api_Welcome extends PhalApi_Api {

    public function say() {
        $rs = array();
        $rs['title'] = 'Hello World!';
        return $rs;
    }
}

2.3 Visit the API

The API service link looks like:

http:// + host + entrance + ?service=XXX.XXX

Yeah out demo link is:

http://dev.phalapi.com/demo/?service=Welcome.Say

2.4 Get the result

PhalApi will response with JSON, so here it is:

{"ret":200,"data":{"title":"Hello World!"},"msg":""}

To make the result more clear,

{
    "ret": 200,
    "data": {
        "title": "Hello World!"
    },
    "msg": ""
}

2.5 Screenshoot

2.5 Congraduations!

You have been smark at develop APIs with PhalApi!
Enjoy it and more detail at PhalApi.