In this video we will build a complete JSON RESTful API using PHP and MySQL. We will use the SlimPHP framework along with PDO to interact with the MySQL database. CODE -https://github.com/bradtrav…
Original source
In this video we will build a complete JSON RESTful API using PHP and MySQL. We will use the SlimPHP framework along with PDO to interact with the MySQL database. CODE -https://github.com/bradtrav…
Original source
34 responses to “RESTful API With PHP & MySQL”
Gods exists if you believe in them :v
great tutorial! this and together with the article i read on laravel api development has really made me understand how APIs work more, the only questions i have left now are: what instances are APIs useful? when/how will i know i should be building one for an application? if anyone could answer, i would greatly appreciate it.
THANK YOU SO MUCH
Hi,
After I add the tags in httpd-vhosts.conf the xampp apache server crashers with the following errors: Error:
Apache shutdown unexpectedly.
11:40:36 AM [Apache] This may be due to a blocked port, missing dependencies,
11:40:36 AM [Apache] improper privileges, a crash, or a shutdown by another method.
11:40:36 AM [Apache] Press the Logs button to view error logs and check
11:40:36 AM [Apache] the Windows Event Viewer for more clues
11:40:36 AM [Apache] If you need more help, copy and post this
11:40:36 AM [Apache] entire log window on the forums
Thank you so much!
thank you so much for this great tutorial, but i have a question that i really hope you answer for me:
now i have three tables on mysql and they're connected by "foreign keys", my question is do i need to do a routes.php for each table to have post, get, put and delete working on them? i'm little confused about this! please clarify!
appreciate you man!
Can you also do a thorough tutorial on stuff like:
– existing customer (emails maybe?)
– optional parameters?
– Authorization / OAuth?
That would be awesome. Thank you!
Why won't work the same procedure with another table in the same database? I've copied the costumers.php file renamed it and I've changed the attributes inside. But unfourtunatly it wont work
You should be using prepared statements and not using raw queries like you did at 36:31
Why not use the $response param in order to generate the response instead of echo-ing ? i'd also singleton the DB connection to have it always available and ready for calls, all in all a great resource, thanks for the tut
Great Vid. I am stuck with the following error and as I'm totally new to php and MySQL I'm not sure how to fix it.
Error:
{"error": { "text": SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES)}
I know its something to do with the password but after that no idea. Any help would be appreciated! Thanks
just finished the tutorial and pushed my code to github…
awesome man, thanks
Amazing. Thx
Thanks! Nicely done. Really useful.I like the way you go from the very beginning.
hi do i need to know slim prior to watching this video, or just an understanding of PHP will do?
Nice video. I use http://apiato.io/ a framework for building API-Centric Apps with PHP, built on top of Laravel.
mmm, good tutorial, but if in route files (files in routes folder) I add $app = new SlimApp , then routes in index.php doesn't work. Without this line it works fine.
I just want to point out that echoing your response is not the correct way to use this Framework.
Instead of doing:
echo json_encode($customers)
Do:
return $response->withStatus(200)
->withHeader('Content-Type', 'application/json')
->write(json_encode($customers));
This will allow you to send custom status codes and custom headers.
can i deploy it in shared hosting?
I please request another video on consuming this API from Angular. I think you need the Angular app to be on the same domain in order to use the API, but there are ways around that. So it would be really helpful to know how to structure the Angular app to work with these API files. Maybe cover the situation where the API is on the same server as the front end app, and another situation where it's not. 🙂
Also, for Anguar, all other Youtube videos assume the backend is Node, but many like me just use a regular non-Node supported hosting company that supports PHP.
Nice tutorial to understand the basics of the slim framework I really Wonder if you could implement a MVC structure in a little project for another tutorial, keep it up! and hope you do a tutorial of what I told you.
Great tutorial
Asking again,
How to get single user detail by name, username or email?
when i am running below url
http://slimapp/api/customers
getting this error
Slim Application Error
A website error has occurred. Sorry for the temporary inconvenience.
Any solution ?
You made My DAY MAN !!! $this->Night($Actually)… Thank you!!!! Excelente Video, I learned a lot! Like echo{'I Know $Kung-Foo->Now()'};
How do you deploy this app to a shared hosting?
Any chance to get a video on a REST(ful) API without any framework?
It is a genuinely exellent video. Thank you
Nice tutorial, exactly what I needed for weeks. Thumbs up!
What stops people from finding the POST url and flooding the DB ?
$stmt = $db->query($sql); this rise Page Not Found
Is there a video on how to consume this API using Javascript/AJAX?
I wonder why I could not find this video in your playlist? I instead do a search and was able to find it.