Live data from Hacker News

PHP RESTful API with an example MySQL database.

github.com

1–6 of 6 posts

PHP RESTful API with an example MySQL database.

#1
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.

PHP RESTful API with an example MySQL database.
github.com

Re: PHP RESTful API with an example MySQL database.

#3
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") {

Re: PHP RESTful API with an example MySQL database.

#4

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!