4 ms·
PHP RESTful API with an example MySQL database.
I recently finished a small RESTful API project for a University project and thought it would be good to upload it to Github as an example as to how a RESTful API should function and work, as I know its hard to find a clear cut solution to RESTful API standards.
Here's a little description of what's included:
PHP RESTful API with an example MySQL database. Comes with various HTTP server response mechanisms, basic HTTP authentication, pagination and rate limits. Do note this API sends a delete request using the JSON body rather than using an ID within the URI.
Feel free to reuse it as you wish.
- trillcode 12y agoI love this for instructional purposes. It is also good for when a very lightweight api is needed. I like how it used more modern OO based php and not some procedural mess. I just thought Id give some positive feedback bro !
- karlhadwen 12y agoThank you!
- blueicelt2004 12y agoI like this but just something small, in api.php at line 341/345 you check if $table is articles and inside the same ifcheck you check again, the same thing is done at 412/416 } else if ($table=="articles") { if (empty($data->article_id)) { $this->data_object->send_response(400); } else { if ($table=="articles") {
- karlhadwen 12y agoDidn't spot that, will take a look, thanks!
- krapp 12y agoUpvoted for using PDO.