Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 3361

[Wiki] Simple Web APIs for your Yii App

$
0
0

NOT COMPETED YET. Still writing ..

Its very common now-a-days to have Mobile app for web apps. For Mobile apps we need web APIs to fetch data or even post/update on web. We found a very simple method to make such interface.

Example: http://example.com/post/index [ HTML Web page ]

API : http://example.com/api/post/index [ JSON Array ]

Procedure:

  • Create new module named 'api'.
  • Copy existing controller post into newly created module.
  • Create new function in controller.php named sendJson()
  • Replace render() calls with sendJson()

And you are almost done.


Viewing all articles
Browse latest Browse all 3361

Trending Articles