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

Sdílet
Vložit
  • čas přidán 26. 05. 2018
  • In this series we will put together a REST API using PHP with NO FRAMEWORK. We will use object oriented programming along with PDO to connect and query a MySQL database.
    Code:
    github.com/bradtraversy/php_r...
    💖 Become a Patron: Show support & get perks!
    / traversymedia
    Website & Udemy Courses
    www.traversymedia.com
    Follow Traversy Media:
    / traversymedia
    / traversymedia
    / traversymedia
  • Věda a technologie

Komentáře • 361

  • @RealToughCandy
    @RealToughCandy Před 6 lety +81

    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  Před 6 lety +11

      RealToughCandy You’re very welcome 😉

    • @_Omni
      @_Omni Před 6 lety +4

      N00B

    • @RealToughCandy
      @RealToughCandy Před 6 lety +13

      @Omni, thank you!

    • @ionutcatalingheorghiu8953
      @ionutcatalingheorghiu8953 Před 4 lety

      @@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 Před 3 lety

      This is pretty epic

  • @MrBenjjj6
    @MrBenjjj6 Před 6 lety +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!

  • @ernestassimutis6239
    @ernestassimutis6239 Před 6 lety +25

    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!

  • @engsiyad
    @engsiyad Před 6 lety +20

    Man you read my mind. I have been searching this for 2 months

  • @FabricioEGiovanni
    @FabricioEGiovanni Před 5 lety +2

    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.

  • @shuckle2134
    @shuckle2134 Před 5 lety

    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 :)

  • @lifelover69
    @lifelover69 Před 5 lety +5

    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 Před 3 lety

      IMO frameworks are for people too lazy to learn the actual language and use it properly.

  • @traceyshock2898
    @traceyshock2898 Před 6 lety +1

    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.

  • @sandy3028
    @sandy3028 Před 4 lety +3

    Doing my first rest api now, feels like my head gonna explode. This video helped me a lot!

  • @toomaxbeat7847
    @toomaxbeat7847 Před 6 lety +14

    That's really cool !! You and your videos are the main reasons to keep learning and continuing in this field

    • @TraversyMedia
      @TraversyMedia  Před 6 lety +3

      TOoma Dev thanks. That actually really means a lot and keeps me going

  • @NicholasIbarra01
    @NicholasIbarra01 Před 6 lety +1

    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!

  • @codesus99
    @codesus99 Před 4 lety +1

    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 🙏🙏🙏🙏🙏

  • @RoulTrid
    @RoulTrid Před 2 lety

    This tutorial was a life saver for me. I made my Rest Api and connected 3 servers. Thank your for this.

  • @Khayabushprojects
    @Khayabushprojects Před 6 lety +4

    I've never loved PHP but this changed my mind i will learn it soon
    hey brad thank you buddy

  • @techware1470
    @techware1470 Před 6 lety

    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!

  • @jaimesastre1046
    @jaimesastre1046 Před 5 lety +1

    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!

  • @riskyrici
    @riskyrici Před 6 lety

    You are our saviour Brad. I can't thank you enough. This is really helpful and it means a lot. Huge fan!!!

  • @jaakkosuninen
    @jaakkosuninen Před 2 lety +1

    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.

  • @wmd6917
    @wmd6917 Před 2 lety

    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!

  • @Tanzeel431
    @Tanzeel431 Před 6 lety +1

    The only code on the internet that actually worked. Thank you for sharing on git.

  • @johnmahugu
    @johnmahugu Před měsícem

    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. :)

  • @justsain3236
    @justsain3236 Před 3 lety

    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 :)

  • @amirzakaria8829
    @amirzakaria8829 Před 2 lety

    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 Před 5 lety

    Very seldom do I run across a video that is as well organized and instructive as this one....thumbs up.

  • @samueltorres2485
    @samueltorres2485 Před 5 lety

    You're tutorials are always lit! Thanks Brad!

  • @florianhermann1558
    @florianhermann1558 Před 5 lety +3

    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 !

  • @Satenc0
    @Satenc0 Před 5 lety +5

    we need a part 4 where you implement this with an user interface :D

  • @garretthamelin3653
    @garretthamelin3653 Před 5 lety

    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!

  • @ramratech1919
    @ramratech1919 Před 4 lety

    hi brad, you explain complex topics in a simple way. Thank you for sharing good tutorials.

  • @stephh4392
    @stephh4392 Před 6 lety

    This is exactly what I want to learn!!!!Thank u!!!!Love your videos!!!

  • @abhishekverma614
    @abhishekverma614 Před 3 lety

    Awesome, this channel never disappoints whenever I come here, thanks a lot !!!

  • @STSN3116
    @STSN3116 Před 6 lety

    I really like the way you stored the entire output in "data"

  • @_Caose
    @_Caose Před 2 lety +1

    This is exactly what I was trying to build. Thank you

  • @herbertk9266
    @herbertk9266 Před 6 lety +3

    Brad your the best thks for your time, thanks for sharing

  • @wsh4and
    @wsh4and Před 6 lety

    Wow, you read my mind 😁. Just what I need for school assignment.

  • @edenr1988
    @edenr1988 Před 5 lety

    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

  • @SajidLatifDK
    @SajidLatifDK Před 6 lety +1

    Thanks for making my day again 👍

  • @Sid629
    @Sid629 Před 5 lety

    Thank you very much for your tutorials Mr. Traversy.

  • @bulldog2024
    @bulldog2024 Před 6 lety

    Great tutorial. Just what I was looking for.

  • @KletoReese
    @KletoReese Před 5 lety

    Excellent timing!! Thank You!

  • @mchamouda4915
    @mchamouda4915 Před 6 lety

    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 .

  • @carollillefield2462
    @carollillefield2462 Před 3 lety

    Thank you for all you do!!!! When in doubt you are my go to!

  • @ryanspivey1819
    @ryanspivey1819 Před 2 lety

    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.

  • @thaof1898
    @thaof1898 Před rokem +1

    thank you so much, i did it :D and deployed it in my own host website

  • @nonchalant8473
    @nonchalant8473 Před 6 lety

    Thank you. Great series... keep it up!

  • @CorporalPoon
    @CorporalPoon Před 6 lety +1

    omg just what i wanted. thank you

  • @rajdhanki8740
    @rajdhanki8740 Před 6 lety

    Just one word awesome u r reading the programmers mind

  • @ChintanUmarani
    @ChintanUmarani Před 6 lety

    simple and well explained, Kudos 👍

  • @donovanfrancis7184
    @donovanfrancis7184 Před 4 lety +1

    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.

  • @timeforrice
    @timeforrice Před rokem

    Great video. Love seeing him making PHP content more

  • @patryk3852
    @patryk3852 Před 4 lety

    Brad, you are like a GOLD!!

  • @reeverbstudios
    @reeverbstudios Před 2 lety

    Nice one Mr! I hope I can get everything you say here...It has been days looking for a good PHP PDO class.

  • @jroseme
    @jroseme Před rokem

    Awesome tutorial, just works.

  • @GauravLonkar
    @GauravLonkar Před 3 lety

    +1 for the Quality of the Code you write. ❤️

  • @helluci6449
    @helluci6449 Před 4 lety +32

    2020 update would be nice

    • @PASTRAMIKick
      @PASTRAMIKick Před 3 lety +6

      PHP is quite old, is there a need for an update?

    • @gothicwave7761
      @gothicwave7761 Před 3 lety

      @@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 Před 2 lety

      Why? php still the same lol

  • @yomyomcam
    @yomyomcam Před 6 lety

    new suscriber today! great videos.

  • @safara_umarov
    @safara_umarov Před 4 lety

    Thank you very much for interesting videos. Respect 😍

  • @edwardmuss
    @edwardmuss Před 5 lety

    Awesome tutorial. Thanks very much

  • @claudwatari
    @claudwatari Před 2 lety

    2021, I'm here. Thanks for this. Very helpful.

  • @rahulvanmali1406
    @rahulvanmali1406 Před 6 lety

    Waiting for a video on docker container + node js microservices! I guess it's in your to-do list

  • @alihekmat2517
    @alihekmat2517 Před 3 lety

    dudeeee you're awesome

  • @mkgamingentertainment3786

    You can replace LEFT JOIN with WHERE clause such as "WHERE p.category_id = c.id" will do the same work as LEFT JOIN

  • @AbdullahAbbasAwan
    @AbdullahAbbasAwan Před 6 lety

    Thank you so much. Please add one more video in this course about HOW to upload whole project or files on GIT & Gist. Thanks

  • @xCodeSoul
    @xCodeSoul Před 5 lety

    For better usage and security for mysql
    Use medoo for execute any sql query , its simple ans secure
    Thanks

  • @gemilaguinaldo6723
    @gemilaguinaldo6723 Před 3 lety

    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

  • @veerth6959
    @veerth6959 Před 5 lety

    Thank you so much sir, it's great video

  • @altepfeife5470
    @altepfeife5470 Před 5 lety

    Wow, awesome. It works, even on the webserver ;)

  • @sfa327
    @sfa327 Před 6 lety +2

    Thank you, you are the best
    Can you do video on how to make it secure and access by token or it required authentication

  • @tarihart8385
    @tarihart8385 Před 6 lety

    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!

  • @womeninmovesolutionschanne1065

    My favourite tutor

  • @luisedudias
    @luisedudias Před 2 lety

    Great video! Thank you very much!

  • @kabirnarayanjha
    @kabirnarayanjha Před 5 lety

    Tq so.much for this gr8 tutorial and code

  • @elricho72
    @elricho72 Před 2 lety

    Great video! thanks for sharing, it is very usefull

  • @sudipmodi3122
    @sudipmodi3122 Před 2 lety

    Great tutorial thank you

  • @KayahanKahrman
    @KayahanKahrman Před 5 lety

    This video made me subscribe to channel. Thanx a lot!

  • @AbhishekKumar-mq1tt
    @AbhishekKumar-mq1tt Před 6 lety

    Thank u for this awesome series, can u make a video series on express, mongodb, nodejs store rest api

  • @jerryurena6370
    @jerryurena6370 Před 5 lety +1

    you should consider adding pagination data filtering to these

  • @druidwtf
    @druidwtf Před 5 lety

    Thank you very good and helpful video :D

  • @robinsonchukwu7295
    @robinsonchukwu7295 Před 3 lety

    Thanks man... God bless you

  • @xcoderteam6972
    @xcoderteam6972 Před 5 lety

    this video is very nice. Thank you for video

  • @hermanling4663
    @hermanling4663 Před 4 lety

    great tutorial! great job!

  • @uweopfern
    @uweopfern Před 5 lety +3

    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 Před 5 lety

      Hello
      Kindly refer me to a tutorial when u find one.
      Thank u

  • @khillofication
    @khillofication Před 6 lety

    Thank you very much it is so useful

  • @riothardy101
    @riothardy101 Před 6 lety

    Thank you Brad :)

  • @LuisOtavioZimmermann
    @LuisOtavioZimmermann Před 4 lety

    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.

  • @bodyandblood
    @bodyandblood Před 4 lety

    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.

  • @MrRicharddaniel
    @MrRicharddaniel Před 6 lety

    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)

  • @waynekille4914
    @waynekille4914 Před 2 lety

    This. Is. Awesome!

  • @DucMinhTeaching
    @DucMinhTeaching Před 3 lety

    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.

  • @abdullahquhtani4247
    @abdullahquhtani4247 Před 3 lety

    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.

  • @rezarst5734
    @rezarst5734 Před rokem

    so useful, thanks

  • @celsofurtado2142
    @celsofurtado2142 Před 4 lety

    Magnific!!

  • @user-sf2ym1ht2g
    @user-sf2ym1ht2g Před rokem

    Super. Thank you.

  • @informatiquedz9800
    @informatiquedz9800 Před 6 lety +1

    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 Před 6 lety +4

      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

  • @salamkottayam490
    @salamkottayam490 Před 5 lety

    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.

    • @user-gz1rc2ik7w
      @user-gz1rc2ik7w Před 5 lety +1

      Thank you for the comment! It saved me a bunch of time.

  • @chaker7778
    @chaker7778 Před 6 lety

    thanks bro .. you are great

  • @mrparadox9683
    @mrparadox9683 Před 4 lety

    awesome tutorial!

  • @kamalhm-dev
    @kamalhm-dev Před 6 lety +4

    Just in case you need an idea, I'm waiting for fullstack Vue.js, but no pressure ;D

  • @jorgevazquez3317
    @jorgevazquez3317 Před 5 lety

    I uploaded my app to my live share hosting server but I get "no page found." as long as I tested the app using php -S localhost:8080/quote it worked, but when I tried using it without the port number, just through apache, it doesn't work. I have created .htaccess file and enabled mod_rewrite in apache according to slim framework web server documentation for apache. How can I get this running in apache? thanks

  • @yaokouassi5176
    @yaokouassi5176 Před 5 lety

    This is awesome!) tthanks you very mutch) Please can you do simple Migration class. Simple class using concept migrations data to the database and simple console from scratch. Thanks you!)