PHP REST API From Scratch [1] - Database & Read

  Рет қаралды 513,154

Traversy Media

Traversy Media

Күн бұрын

Пікірлер: 361
@RealToughCandy
@RealToughCandy 6 жыл бұрын
This is awesome! Can't wait to watch it all later tonight. We use an older framework to build our APIs (Apigility) at work and the documentation sucks. I think this is the series I need to understand what's going on under the hood. Thank you!!
@TraversyMedia
@TraversyMedia 6 жыл бұрын
RealToughCandy You’re very welcome 😉
@_Omni
@_Omni 6 жыл бұрын
N00B
@RealToughCandy
@RealToughCandy 6 жыл бұрын
@Omni, thank you!
@ionutcatalingheorghiu8953
@ionutcatalingheorghiu8953 4 жыл бұрын
@@RealToughCandy hah.. Just saw one of your videos. And what a coïncidence. 1st comment i see is yours ! This means i need to subscribe ! 😂
@MrBoiks
@MrBoiks 3 жыл бұрын
This is pretty epic
@MrBenjjj6
@MrBenjjj6 6 жыл бұрын
For those like me who are still quite new, doing it without frameworks is really useful as I actually learn a lot about how things work. Thank you!
@johnmahugu
@johnmahugu 5 ай бұрын
this is awesome, i created a php api from scratch today at work and this video goes to show me what needs to be improved as i made it in pure php, thanks alot. :)
@lifelover69
@lifelover69 6 жыл бұрын
Thank you for doing this with NO FRAMEWORK! Frameworks come and go, but the language remains. Many tutorials use {insert current trendy framework}, which obscures the inner workings of php. Great job done, mate.
@andresz1606
@andresz1606 4 жыл бұрын
IMO frameworks are for people too lazy to learn the actual language and use it properly.
@codesus99
@codesus99 4 жыл бұрын
I've spent 3weeks studying how API works but I didn't find any helpful resource like this serie. Thank you man we appreciate u. Please help us with a php PDO series with an simple project example 🙏🙏🙏🙏🙏
@traceyshock2898
@traceyshock2898 6 жыл бұрын
I love PHP and have been using it off and on for about 10 years. I don't program full time. But i am always trying to learn new things. Thank you Brad, you are a really good instructor. I will be checking out your other courses. I actually learned a lot.
@noorulhudachoudhary7009
@noorulhudachoudhary7009 2 жыл бұрын
I love normal humans
@ernestassimutis6239
@ernestassimutis6239 6 жыл бұрын
these little project series most exciting thing on your channel, thank you! I started my developer career a month ago, your role in it was HUGE Brad!
@RoulTrid
@RoulTrid 2 жыл бұрын
This tutorial was a life saver for me. I made my Rest Api and connected 3 servers. Thank your for this.
@wmd6917
@wmd6917 3 жыл бұрын
As an old Informix DBA, esql server side vi guy I found this demo dead simple and it demystified what all the kiddies drone on about these days. Well done sir!
@engsiyad
@engsiyad 6 жыл бұрын
Man you read my mind. I have been searching this for 2 months
@jaakkosuninen
@jaakkosuninen 3 жыл бұрын
Calm and clear presentation. I tried and got this working. Thank you very much. Now I can take my time to get acquainted to it.
@NicholasIbarra01
@NicholasIbarra01 6 жыл бұрын
Why? Why do you make life's hardest problems seem like nothing?! Your videos never fail to impress, you have a true talent. Thank you for this, I was looking for an easy way to implement a PHP back end without using an adapter framework. This is perfect!
@shuckle2134
@shuckle2134 5 жыл бұрын
Brad, not only are you a very bright and intelligent person, but you also posses the generosity to make amazing and professional tutorials like these for the community to view for free. Hats of to you sir :)
@DucMinhTeaching
@DucMinhTeaching 3 жыл бұрын
For most databases, PDOStatement::rowCount() does not return the number of rows affected by a SELECT statement. Instead, use PDO::query() to issue a SELECT COUNT(*) statement with the same predicates as your intended SELECT statement, then use PDOStatement::fetchColumn() to retrieve the number of matching rows.
@FabricioEGiovanni
@FabricioEGiovanni 6 жыл бұрын
Awesome video! I'm currently migrating to Web Development and these 32:17 minutes gave me a bunch of valuable stuff + the main theme of the video. I've subscribed and will certainly watch the other classes. Thanks for your great contribution Brad.
@toomaxbeat7847
@toomaxbeat7847 6 жыл бұрын
That's really cool !! You and your videos are the main reasons to keep learning and continuing in this field
@TraversyMedia
@TraversyMedia 6 жыл бұрын
TOoma Dev thanks. That actually really means a lot and keeps me going
@justsain3236
@justsain3236 3 жыл бұрын
I've been integrating 3rd party API's recently and finally got given the task of creating an endpoint, i managed to figure it out although it wasn't my best work....always learning though so.....here i am. Great vid :)
@sandy3028
@sandy3028 5 жыл бұрын
Doing my first rest api now, feels like my head gonna explode. This video helped me a lot!
@mkgamingentertainment3786
@mkgamingentertainment3786 4 жыл бұрын
You can replace LEFT JOIN with WHERE clause such as "WHERE p.category_id = c.id" will do the same work as LEFT JOIN
@donovanfrancis7184
@donovanfrancis7184 4 жыл бұрын
Thanks for this really good tutorial! All the documentation that I have read indicates that the PDOStatement::rowCount method is not guaranteed to work for mysql databases. One way to workaround this is to do a "Select count(*) " using the same where conditions as the original query then fetch the results.
@Tanzeel431
@Tanzeel431 6 жыл бұрын
The only code on the internet that actually worked. Thank you for sharing on git.
@ryanspivey1819
@ryanspivey1819 3 жыл бұрын
Great tutorial, Brad. My only critique would be using the post table as an example since I'm so new to the PHP syntax, I felt confused at times if you were making a POST request or referencing the post table. That may just be me though.
@mchamouda4915
@mchamouda4915 6 жыл бұрын
Really very Nice i Watched Many Videos About Restful API but i'm not understand well but when i watched this video i gated Helpful now i'm creating my own API without any other Help thank you Very Much , sorry for my Bad English .
@techware1470
@techware1470 6 жыл бұрын
Hey thanks man! I'am currently working on my own CMS to make it easy for my clients to change text and all that stuff on the websides I build for them. It's all based on PHP in the backend and this tutorial is just what I was looking for. Because I#m experimenting with object oriented PHP and not that happy with my solution so far. So great that you help me with new input!
@florianhermann1558
@florianhermann1558 5 жыл бұрын
Hi Brad, thanks for your work. If I can suggest you something : I know the goal is to make something from scratch but you could use composer for autoloading and a basic router like Fast Route. It will be a more real world approach !
@jaimesastre1046
@jaimesastre1046 5 жыл бұрын
wow, just saw your video. Great presentation making it all so easy. I knew all the pieces, but here put together so structured and clear, just perfect!! Bravo!
@Satenc0
@Satenc0 6 жыл бұрын
we need a part 4 where you implement this with an user interface :D
@helluci6449
@helluci6449 4 жыл бұрын
2020 update would be nice
@PASTRAMIKick
@PASTRAMIKick 3 жыл бұрын
PHP is quite old, is there a need for an update?
@gothicwave7761
@gothicwave7761 3 жыл бұрын
@@PASTRAMIKick It's about as old as Java, Python, and Javascript, and it's being regularly updated? That said this is still PHP 7, so there's probably little to no need to for an update.
@nobytes2
@nobytes2 3 жыл бұрын
Why? php still the same lol
@_Caose
@_Caose 2 жыл бұрын
This is exactly what I was trying to build. Thank you
@Khayabushprojects
@Khayabushprojects 6 жыл бұрын
I've never loved PHP but this changed my mind i will learn it soon hey brad thank you buddy
@amirzakaria8829
@amirzakaria8829 2 жыл бұрын
It was so professional. appreciation in an infinite loop. wow. expressions, style of coding, explanation, logic and procedure was so ideal. Thank you man. Thanks a lot. You are one of a kind really. We need you and more like you.
@jackmanjls
@jackmanjls 5 жыл бұрын
Very seldom do I run across a video that is as well organized and instructive as this one....thumbs up.
@truthShallPrevailRRVS
@truthShallPrevailRRVS 4 жыл бұрын
TIp: IMO An easier (and cleaner) way to write SQL queries is by using double quotes and flower braces when you're including an object/associativeArray element. $fetchLimit = 5; $filter = array("month"=>"2020-08-30"); $query = " SELECT * FROM posts WHERE user_id='{$params->user_id}' AND month='{$filter['month']}' LIMIT $fetchLimit ; ";
@spencer5028
@spencer5028 2 жыл бұрын
Should use prepared statements when accepting user inputs, a few extra steps but safer and many useful properties
@edenr1988
@edenr1988 5 жыл бұрын
Hey awesome video ! btw, just to point out you could save more line of codes using PDO::FETCH_CLASS, because you already have models for this case, something like: $row = $result->fetch(PDO::FETCH_CLASS, 'Post'); then you could just json_encode that object
@abhishekverma614
@abhishekverma614 4 жыл бұрын
Awesome, this channel never disappoints whenever I come here, thanks a lot !!!
@STSN3116
@STSN3116 6 жыл бұрын
I really like the way you stored the entire output in "data"
@salamkottayam490
@salamkottayam490 5 жыл бұрын
Very well explained and easy to understand. if You can add utf8 support for the data also it will be helpful. Because while I implement for utf-8 it got stuck and i found the solution. Add : $this->conn->exec("set names utf8"); right after the new PDO statement in Database class. Thank You dear.
@ГерманТитов-ь6у
@ГерманТитов-ь6у 5 жыл бұрын
Thank you for the comment! It saved me a bunch of time.
@claudwatari
@claudwatari 2 жыл бұрын
2021, I'm here. Thanks for this. Very helpful.
@timeforrice
@timeforrice Жыл бұрын
Great video. Love seeing him making PHP content more
@BlaugranaBanters
@BlaugranaBanters 6 жыл бұрын
You are our saviour Brad. I can't thank you enough. This is really helpful and it means a lot. Huge fan!!!
@reeverbstudios
@reeverbstudios 2 жыл бұрын
Nice one Mr! I hope I can get everything you say here...It has been days looking for a good PHP PDO class.
@uweopfern
@uweopfern 5 жыл бұрын
I love this so much currently having project that i am developing APIS in core php using PDO, can you please make authentication using JWT
@sodiqoyedotun3185
@sodiqoyedotun3185 5 жыл бұрын
Hello Kindly refer me to a tutorial when u find one. Thank u
@rosselliot8971
@rosselliot8971 6 жыл бұрын
Brad, what's really needed are authentication tuts for APIs, JWT or otherwise.
@TaelurAlexis
@TaelurAlexis 6 жыл бұрын
Ross Elliot he seriously already has videos on that.
@rosselliot8971
@rosselliot8971 6 жыл бұрын
TaelurAlexis seriously?
@ramratech1919
@ramratech1919 5 жыл бұрын
hi brad, you explain complex topics in a simple way. Thank you for sharing good tutorials.
@patryk3852
@patryk3852 4 жыл бұрын
Brad, you are like a GOLD!!
@garretthamelin3653
@garretthamelin3653 5 жыл бұрын
Dude, thank you!!!! you're the hero we need but not the one that we deserve.... If we ever meet in person drinks are on me!
@samueltorres2485
@samueltorres2485 6 жыл бұрын
You're tutorials are always lit! Thanks Brad!
@MrRicharddaniel
@MrRicharddaniel 6 жыл бұрын
More PHP Please.... All Freelancers need to learn PHP to get mroe clients from all small businesses or wordpress. Please make more content focused on freelancing (PHP)
@rajdhanki8740
@rajdhanki8740 6 жыл бұрын
Just one word awesome u r reading the programmers mind
@bidam1984
@bidam1984 6 жыл бұрын
I love PHP, but PHP friendzoned me
@KD-xp4di
@KD-xp4di 5 жыл бұрын
Oh man. You too?
@spacenodus7959
@spacenodus7959 5 жыл бұрын
Python will never friendzone you
@Aru_im
@Aru_im 5 жыл бұрын
It's funny because in my language PHP stand for "Pemberi Harapan Palsu" translated as "False Promise Giver" as in friendzone.
@commanderbensisko
@commanderbensisko 5 жыл бұрын
Should have bought some phlowers every once in a while
@thecardboardboyz6320
@thecardboardboyz6320 5 жыл бұрын
Orang indonesia detected
@carollillefield2462
@carollillefield2462 3 жыл бұрын
Thank you for all you do!!!! When in doubt you are my go to!
@thaof1898
@thaof1898 Жыл бұрын
thank you so much, i did it :D and deployed it in my own host website
@bodyandblood
@bodyandblood 5 жыл бұрын
Many thanks. The ajaxCall.html form id should read 'form' and not 'apiform' . This is necessary so as to match var url = $('form').serialize(); in the ajaxCall.js file. Now ajaxCall.html will work. Very small correction in a magnificent tutorial. Bless you.
@astianmuchui
@astianmuchui 3 жыл бұрын
In all honesty, This is my coding university
@womeninmovesolutionschanne1065
@womeninmovesolutionschanne1065 2 жыл бұрын
My favourite tutor
@kamalhm-dev
@kamalhm-dev 6 жыл бұрын
Just in case you need an idea, I'm waiting for fullstack Vue.js, but no pressure ;D
@TraversyMedia
@TraversyMedia 6 жыл бұрын
Kamal Mahmud ill keep that in mind 😉
@johnjavieridmilao5247
@johnjavieridmilao5247 5 жыл бұрын
@@TraversyMedia good job
@gemilaguinaldo6723
@gemilaguinaldo6723 3 жыл бұрын
now i understand how fast we create api's via frameworks. there's so many tedious codes. but I think this will be faster as we are using vanilla php
@shivadigitalweb9265
@shivadigitalweb9265 6 жыл бұрын
Hi, Brad. Could you please make video tutorials on JWT/Auth REST API in PHP and Laravel. I could not find any videos on your channel based on Authentication. Thanks.
@sodiqoyedotun3185
@sodiqoyedotun3185 5 жыл бұрын
Hello Kindly refer me to a tutorial when u find one. Thank u
@Mohammed24441
@Mohammed24441 4 жыл бұрын
kzbin.info/aero/PLe30vg_FG4OSbizS6Gpw_LICp9zBcmjZU
@mstafadev6729
@mstafadev6729 6 жыл бұрын
i' am always wondering how you manage your time bcs this is not easy man, thank you
@TraversyMedia
@TraversyMedia 6 жыл бұрын
mstafa dev its hard but luckily its part my full time job
@mattlyxd
@mattlyxd 6 жыл бұрын
It'd be neat to see an episode about how you manage your time for the rest of us, maybe give us some pointers? :) I've also wondered as I'm trying to catch up with you! Absolute huge fan of your channel!
@IsfhanAhmed
@IsfhanAhmed 6 жыл бұрын
me also wana meet you
@SajidLatifDK
@SajidLatifDK 6 жыл бұрын
Thanks for making my day again 👍
@YoannesGeisslersilva
@YoannesGeisslersilva 6 жыл бұрын
For me it makes way easier to understand: $str_concat = "mysql:host=$this->host;dbname=$this->db_name"; Dot/quotes/dots/quotes are quite confusing sometimes.
@GauravLonkar
@GauravLonkar 4 жыл бұрын
+1 for the Quality of the Code you write. ❤️
@herbertk9266
@herbertk9266 6 жыл бұрын
Brad your the best thks for your time, thanks for sharing
@brandondelacruz934
@brandondelacruz934 4 жыл бұрын
Also, confusing note. Why do you have to type in $posts_arr = array(); $posts_arr['data'] = array(); When you can just say $posts_arr['data'] = array(); and remove the first one
@jroseme
@jroseme Жыл бұрын
Awesome tutorial, just works.
@shovkatmasimova1885
@shovkatmasimova1885 3 жыл бұрын
First thank you for this video. I have a question. In the Read API data from db is coming with "data" object ( example: {"data":[{"id":"30","title":"","body":"","author":"","category_id":"0","category_name":null}]} ). How can I do this for the CREATE API. So how can I send data to the database in the "data" object? (example: {"data":[{"id":"15","title":"test","body":"test","author":"test","category_id":"15","category_name":null}]} )
@Sid629
@Sid629 6 жыл бұрын
Thank you very much for your tutorials Mr. Traversy.
@abdullahquhtani4247
@abdullahquhtani4247 3 жыл бұрын
Could you please send the method to connect to MSSQL Server? And also confirm whether it is gonna be slow unless using ODBC some ppl said that It’s slow when use PDO with SQL server. Thank you.
@LuisOtavioZimmermann
@LuisOtavioZimmermann 4 жыл бұрын
Hey Brad! There's a tutorial on how to add auth on that API? I've been searching that for a long time and still didn't found. Thanks for all the help and all of those videos. You'r videos are amazing, big thanks from Brazil.
@JanJanuszNosacz
@JanJanuszNosacz 3 жыл бұрын
Really appreciate all those comments in code.
@molotovctail6972
@molotovctail6972 6 жыл бұрын
I've been looking at your Slim REST tutorial - is this new approach preferred or are they very similar? I know the Slim tutorial is two years old now. And thanks for the tutorials and much appreciate your down to earth approach!
@tarihart8385
@tarihart8385 6 жыл бұрын
Thanks for this series.Please make a series on vuejs,angular 5 or reactjs and graphql with mongodb.Also a series on sailsjs auth with passport.Or using vuejs, angular with a symfony 4 api.Or angular with laravel.Or this api with vuejs or angular.Or vuejs or angular with ruby on rails.Or authentication with adonisjs.Or vuejs or angular with an adonisjs api!Hope you consider these in future!Thanks anyways!
@bulldog2024
@bulldog2024 6 жыл бұрын
Great tutorial. Just what I was looking for.
@sfa327
@sfa327 6 жыл бұрын
Thank you, you are the best Can you do video on how to make it secure and access by token or it required authentication
@tiny6912
@tiny6912 6 жыл бұрын
There's no need for the $row extraction and the existence of the $post_item. Just do $row['body'] = html_entity_decode($row['body']); and array_push($posts_arr['data'],$row); to get the same result with less code.
@jerryurena
@jerryurena 5 жыл бұрын
you should consider adding pagination data filtering to these
@yomyomcam
@yomyomcam 6 жыл бұрын
new suscriber today! great videos.
@stephh4392
@stephh4392 6 жыл бұрын
This is exactly what I want to learn!!!!Thank u!!!!Love your videos!!!
@wsh4and
@wsh4and 6 жыл бұрын
Wow, you read my mind 😁. Just what I need for school assignment.
@informatiquedz9800
@informatiquedz9800 6 жыл бұрын
Hello, thank you for all your videos :) can you make a video to haw secure passwords before storing them in the database in PHP? And will you do more courses about PHP?
@Alturic
@Alturic 6 жыл бұрын
It's as simple as - $hashedPassword = password_hash($providedPassword) - , of course you get set the algorithm, provide an actual salt if you want, etc. php.net/manual/en/function.password-hash.php
@ChintanUmarani
@ChintanUmarani 6 жыл бұрын
simple and well explained, Kudos 👍
@zealousprogrammer4539
@zealousprogrammer4539 6 жыл бұрын
Hello everyone, Brad I suggest a tutorial with Pusher Chakit - it's one of the service Pusher offers (completely free for now in beta) to create chat app cli/frontend applications easily. Thanks
@xCodeSoul
@xCodeSoul 5 жыл бұрын
For better usage and security for mysql Use medoo for execute any sql query , its simple ans secure Thanks
@andreranulfo-dev8607
@andreranulfo-dev8607 4 жыл бұрын
PHP is life.
@waynekille4914
@waynekille4914 3 жыл бұрын
This. Is. Awesome!
@rumpeltv1080
@rumpeltv1080 6 жыл бұрын
Awesome video! Which font are you using?
@rahulvanmali1406
@rahulvanmali1406 6 жыл бұрын
Waiting for a video on docker container + node js microservices! I guess it's in your to-do list
@Sm0ke821
@Sm0ke821 6 жыл бұрын
thanks THANKS my teacher never explained how the fuck do an api rest and told us you have google.......... THANKS YOU SAVED ME 6 MONTHS WITH THAT TEACHER AGAIN LOVE FROM CHILE (the country xD)
@wendellfaustino2301
@wendellfaustino2301 2 жыл бұрын
Hi thanks for this video. How to use stored procedure in this kind of method?
@DucMinhTeaching
@DucMinhTeaching 3 жыл бұрын
Hi, thank you for the video. I wonder why the result of the query is a boolean? This confuses me so much!
@Fowrli
@Fowrli 4 жыл бұрын
dudeeee you're awesome
@cameracoverage3837
@cameracoverage3837 2 жыл бұрын
Please make a video How to use MVC model with API and Ajax in php 🙏
@jediampm
@jediampm 4 жыл бұрын
some questions: why not using routes and prettier URL ( without php extension)? why are you not restrict the loading data only for get?
@KletoReese
@KletoReese 5 жыл бұрын
Excellent timing!! Thank You!
@AbdullahAbbasAwan
@AbdullahAbbasAwan 6 жыл бұрын
Thank you so much. Please add one more video in this course about HOW to upload whole project or files on GIT & Gist. Thanks
@celsofurtado2142
@celsofurtado2142 5 жыл бұрын
Magnific!!
@brandondelacruz934
@brandondelacruz934 4 жыл бұрын
How do you know what to already type? Experience? I think its gonna be a week before i completely wrap my head around most of it.
@elricho72
@elricho72 2 жыл бұрын
Great video! thanks for sharing, it is very usefull
@nonchalant8473
@nonchalant8473 6 жыл бұрын
Thank you. Great series... keep it up!
@Mike-ku9jf
@Mike-ku9jf 6 жыл бұрын
What should I choose to become full stack php or node js? what will be "better" ?
PHP REST API From Scratch [2] - Single & Create
25:01
Traversy Media
Рет қаралды 147 М.
CAN YOU DO THIS ?
00:23
STORROR
Рет қаралды 48 МЛН
Random Emoji Beatbox Challenge #beatbox #tiktok
00:47
BeatboxJCOP
Рет қаралды 53 МЛН
Smart Sigma Kid #funny #sigma
00:14
CRAZY GREAPA
Рет қаралды 103 МЛН
What Is A RESTful API? Explanation of REST & HTTP
18:38
Traversy Media
Рет қаралды 1,4 МЛН
What is a REST API?
9:12
IBM Technology
Рет қаралды 1,6 МЛН
REST API - что это? Создаем API с нуля на Express
1:21:28
Владилен Минин
Рет қаралды 308 М.
What is Postman and why everyone use it ?
28:33
Hitesh Choudhary
Рет қаралды 32 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 211 М.
PDO Crash Course (PHP)
45:35
Traversy Media
Рет қаралды 278 М.
JSON Crash Course
24:49
Traversy Media
Рет қаралды 1 МЛН
CAN YOU DO THIS ?
00:23
STORROR
Рет қаралды 48 МЛН