In this chapter, we wil explore how to enjoy developing an API in the shortest time.
Here we go!
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;
}
}
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
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": ""
}
You have been smark at develop APIs with PhalApi!
Enjoy it and more detail at PhalApi.