Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building a REST API quickly from a Database model

Tags:

rest

php

mysql

api

I've designed my database diagram(11 entites) for my prototype application. I need to have an REST API on top of this that will allow me to build a prototype android tablet application that talks to it.

Considering this is only for prototype purposes. What would be the quickest way to get a API up and running that would allow me to get, put, delete etc..

Security at this point isn't an issue so even if all add edit delete were open that would be fine.

My initial idea is to build this with PHP and MySQL maybe using the Yii framework to help but I feel there might be something that might be faster for my purpose.

Any thoughts or recommendations or advice?

like image 848
Derek Organ Avatar asked Nov 02 '11 15:11

Derek Organ


2 Answers

It is worth looking into API rapid-prototyping tools like Apify (tutorial) since you're starting from scratch. If you're planning to have both an API and a Web site accessing the same data, consider using one framework for both as it helps prevent duplicating logic. CakePHP and Yii are good examples of multipurpose frameworks that are suited for this type of development.

like image 167
Justin ᚅᚔᚈᚄᚒᚔ Avatar answered Sep 19 '22 08:09

Justin ᚅᚔᚈᚄᚒᚔ


If Python is an option, it is trivial to use a light-weight http framework to build a REST API that accesses a database.

Here's a snippet for a fully functioning http server using the itty framework: https://github.com/toastdriven/itty/blob/master/examples/web_service.py and https://github.com/toastdriven/itty/blob/master/examples/posting_data.py

like image 38
Raymond Hettinger Avatar answered Sep 19 '22 08:09

Raymond Hettinger