Hacker News new | ask | show | jobs
PHP RESTful API with an example MySQL database. (github.com)
7 points by karlhadwen 4420 days ago
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.

3 comments

I 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") {
Didn't spot that, will take a look, thanks!
I 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 !
Thank you!
Upvoted for using PDO.