Database connection & Migrations - Part 3 | PHP MVC Framework from Scratch

Поделиться
HTML-код
  • Опубликовано: 8 янв 2025

Комментарии • 83

  • @josechirino5168
    @josechirino5168 4 года назад +10

    Thanks a lot man, all this content is gold. You are potentially the best PHP teacher on youtube. Please keep it up with your content

  • @ylmazkadan568
    @ylmazkadan568 3 года назад +6

    I was quite mesmerized. I can swear it's the best tutorial series I've ever seen in my life. Your content is very high quality. Thanks to you, I learned very well how Laravel and similar frameworks are developed. When I'm bored, I watch the video series. I will code soon. Gold content. thank you so much

    • @TheCodeholic
      @TheCodeholic  3 года назад +1

      Wow. Thanks buddy for such words.

  • @khanprinters7104
    @khanprinters7104 11 месяцев назад +1

    Awesome series, what I most enjoy about this series is that you take us with you in your thought process about how to implement things and what the pros and cons are when you implement them. Thank you very much

    • @TheCodeholic
      @TheCodeholic  11 месяцев назад

      Thank you my friend for such a nice comment.

  • @fleckenfurz77
    @fleckenfurz77 2 года назад +1

    Simply awesome how you demystify the features that laravel, symfony, etc have!
    Thx a lot for this great tutorial! Learnt a lot!

  • @asadbekdeveloper4599
    @asadbekdeveloper4599 2 года назад +1

    Thank you Zura . Never stop teaching us 🙂🙂🙂🙂

  • @hayatzee8830
    @hayatzee8830 2 года назад +1

    Thanks to the best PHP teacher

  • @shaikhanuman8012
    @shaikhanuman8012 4 года назад +1

    very good information tq for provoding great lectures. keep move on always providing good content.

  • @rajabhishek2936
    @rajabhishek2936 4 года назад +2

    Thank you so much for this amezing course.god bless you bro

  • @ahmedal-raii8184
    @ahmedal-raii8184 3 года назад +1

    Good Job, Please keep making such good content on php

  • @JesperSkelgaard
    @JesperSkelgaard 3 года назад +2

    Great ways todo alot of the items, but i suggest to change the following:
    change in .env file to be DB_DSN = "..." or do one parameter for each and create your own DSN string
    which makes you able to do
    $env = parse_ini_file(dirname(__DIR__).'\.env');
    and no need for depending on vlucas/phpdotenv

  • @maelstrom57
    @maelstrom57 3 года назад

    This series is excellent. Great job.

  • @mustafaagha8834
    @mustafaagha8834 3 года назад +1

    Awesome tutorial

  • @47Lancelot
    @47Lancelot 4 года назад

    Great lesson! Didn’t know this trick with converting array to string so PDO can eat an array like that :) php isn’t trendy but is still awesome tool

  • @dccastro2182
    @dccastro2182 4 года назад

    Thanks for video !! I'm feeling so profissional with your tutorials 😁😁😁!!
    .

  • @murunwascengy2762
    @murunwascengy2762 4 года назад

    Thank you again for very informative tutorial 🥇🥇🥇

  • @SPOKOZE2
    @SPOKOZE2 4 года назад

    2:30 your cursor in the "File name" field is flashing differently than mine... ;D

  • @learntoswim512
    @learntoswim512 Год назад +1

    Any advice for help with the migrations? I saw this comment on free code camp since it wasn't working the original code:
    className = pathinfo($migration, PATHINFO_FILENAME);
    $class = "app\migrations\\" . $className;
    $instance = new $class;
    echo "Applying migration $migration ..." . PHP_EOL;
    $instance->up();
    echo "Applied migration $migration" . PHP_EOL;
    When I try to substantiate an instance with new $class, I get the following error: Cannot declare class m0001_initial, because the name is already in use. No namespace on a m000 files. Thanks!

  • @belafekete3125
    @belafekete3125 4 года назад +1

    Hi!
    I followed this tutorial and everything went good until 30:40, I made instance of class, but after during testing, I got the following error message:
    PHP Fatal error: Uncaught Error: Class 'm0001_initial' not found in /Library/WebServer/Documents/01_Sajat/PhpOopMVC/app/core/Database.php:53
    Stack trace:
    #0 /Library/WebServer/Documents/01_Sajat/PhpOopMVC/migrations.php(22): App\app\core\Database->applyMigrations()
    #1 {main}
    thrown in /Library/WebServer/Documents/01_Sajat/PhpOopMVC/app/core/Database.php on line 53
    Fatal error: Uncaught Error: Class 'm0001_initial' not found in /Library/WebServer/Documents/01_Sajat/PhpOopMVC/app/core/Database.php:53
    Stack trace:
    #0 /Library/WebServer/Documents/01_Sajat/PhpOopMVC/migrations.php(22): App\app\core\Database->applyMigrations()
    #1 {main}
    thrown in /Library/WebServer/Documents/01_Sajat/PhpOopMVC/app/core/Database.php on line 53
    belaf.@Bela-Mac-mini PhpOopMVC %
    Please, help to solve this problem!
    Thanks, Bela

    • @steliossp3368
      @steliossp3368 3 года назад +1

      I have exactly the same problem and I can' t find a solution . Only if inside database.php at the top insert use app\migrations\m0001_initial and create an instance like new m0001_initial() and not as value of variable $className works. Is there an explenation about this error -> Class 'm0001_initial' not found in. Thank you.
      Ok I found the problem. Because in the example we include the migration files to use them for instance if you have at the top of m0001_initial.php "use\migrations" then you have to remove this line. Hope this helps.

  • @tojikacademy
    @tojikacademy 4 года назад +1

    very informative)

  • @mouradeljayi584
    @mouradeljayi584 3 года назад +1

    how we can execute the down method from terminal ?

  • @RasonYudha
    @RasonYudha 9 месяцев назад

    I'm having this particular error where I can't connect to my database and the error will refer to my PDO connection line. I'm sure that I've followed all the instructions carefully and there's no error before I reach to the connection part. Also when I try to run the local server using xampp, I got different type of error where it says Uncaught Error: Typed property app\core\Application::$controller must not be accessed before initialization. Why does it happens and why the error is different?
    Appreciate for any help.

  • @armineyvazi9492
    @armineyvazi9492 2 года назад

    soltani dadash

  • @Kay8B
    @Kay8B 3 года назад +2

    For anyone having issues with Uncaught PDOException: SQLSTATE[3D000]:
    for some reason putting the port last worked for me.
    mysql:host=localhost;dbname=dbname;port=3306

  • @BJK_kasva
    @BJK_kasva 4 года назад

    Thanks for video 😘

  • @iBusik
    @iBusik Год назад

    How is the down() method triggered?

  • @armineyvazi9492
    @armineyvazi9492 2 года назад

    damet garm

  • @geneartista9714
    @geneartista9714 4 года назад +2

    Create a tutorial using AJAX sir, I`m quite curious on how you do it

  • @ayoubbablil6990
    @ayoubbablil6990 2 года назад +1

    hello , its okey if i used mysqli instead of pdo ?

    • @TheCodeholic
      @TheCodeholic  2 года назад +1

      May I know the reason why?

    • @ayoubbablil6990
      @ayoubbablil6990 2 года назад

      @@TheCodeholic I'm good at Mysqli but I've never used pdo before , will that affect something in the next episodes ?

  • @denyserurangwa9581
    @denyserurangwa9581 4 года назад

    Hello!! So cool! Am a new lunix mint user. Been trying to run migrations with no success. Please help😊. Watched tones and tones of videos but it's not working😫. Wanna be able to follow the creation of the framework alongside.

  • @belafekete3125
    @belafekete3125 4 года назад +1

    Hi!
    I really like your video. Until this part, everything went well and everything was okay, but now I got this error message:
    Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory.
    I'm using XAMP on macOS Catalina 10.15.7.

    • @TheCodeholic
      @TheCodeholic  4 года назад +2

      Probably mysql is not started. Check it...

  • @ashiktopu8134
    @ashiktopu8134 2 года назад

    Hey, man. Can you please make a video about ORM and DBAL?

  • @topalek
    @topalek 4 года назад +1

    Do you will implement a DI container for this project?

    • @TheCodeholic
      @TheCodeholic  4 года назад +5

      No, I have not implemented it but I may update the framework and record on DI also if many people asks.

    • @marceladonicova571
      @marceladonicova571 4 года назад

      @@TheCodeholic Yes, I want this too

    • @rxxt-sh1vj
      @rxxt-sh1vj 4 года назад

      @@TheCodeholic Please make a dependency injector from scratch and include it in framework..It would be way more better

  • @issaissifou4959
    @issaissifou4959 3 года назад

    Thank you so much!

  • @geneartista9714
    @geneartista9714 4 года назад

    Is this how also in Frameworks like Laravel/CodeIgniter is done, because once I was able to grasp your lessons, I want to jump in to Laravel, so what I mean is I want to use your Lesson as a key in order for me to start learning Larave

    • @TheCodeholic
      @TheCodeholic  4 года назад +1

      Firat of all get familiar with OOP if you are not yet.
      I have a full playlist about Object Oriented PHP.
      This video series will definitelly help also to better understand how frameworks work.

    • @geneartista9714
      @geneartista9714 4 года назад

      @@TheCodeholic I think i`m quite familiar with OOP ever since 3 weeks ago I always used OOP to make my code reusable as much as possible but I`ll watch your OOP videos it`s good to refresh myself again about it even though I`ve been using it for a lot of times now

    • @TheCodeholic
      @TheCodeholic  4 года назад

      If you are good with OOP, go ahead and jump into Laravel or any other framework.

  • @Gandobilis
    @Gandobilis 2 года назад +1

    💫

  • @أحمدكلش-ض3ع
    @أحمدكلش-ض3ع 2 года назад

    what is the name of the theme u r using

  • @liveofcoder
    @liveofcoder 4 года назад

    23:04 how to auto complite var_dump() with echo '', thank you bro

    • @TheCodeholic
      @TheCodeholic  4 года назад +1

      You need to configure code snippet (Live template)

    • @liveofcoder
      @liveofcoder 4 года назад

      @@TheCodeholic thank

  • @atifraja7410
    @atifraja7410 4 года назад

    Hi, Thanks for your video and i have a problem on migration idont know how to handle this the problem is "Fatal error: Uncaught PDOException: SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected in C:\xampp\htdocs\myFrameWork\core\Database.php". can you please tell me what wrong with it? Thanks!

    • @atifraja7410
      @atifraja7410 4 года назад

      its working with this method (database.table).. so did i miss something?

    • @TheCodeholic
      @TheCodeholic  4 года назад

      Make sure you have specified database name in configuration file

    • @atifraja7410
      @atifraja7410 4 года назад

      @@TheCodeholic the name is correct i follow you step by step. Everything is fine expect this.. every time when I call CRUD func i need notation method(database.table).

  • @timwuuk
    @timwuuk 4 года назад

    Again great tutorial. Got migration class not found in core folder error when run migration. I know it should search migrations folder rather than core folder. I follow exact every steps including add require_once in the applyMigrations function. Any body can help? thanks

    • @TheCodeholic
      @TheCodeholic  4 года назад

      I will check this when I will be at computer.

    • @timwuuk
      @timwuuk 4 года назад

      @@TheCodeholic Thanks for your reply. I mamually add full path to the ClassName variable to fix it. I think it's just my autoload setting is slightly different.

    • @mouradeljayi584
      @mouradeljayi584 3 года назад +2

      @@timwuuk if you remove the namespace in the m0001_initial.php and m0001_something.php files it will work

  • @mohammadtaheri98
    @mohammadtaheri98 4 года назад

    hi, i have a problem with connecting to database. i'm using lampp for mysql and for my other projects work just fine. but in this project i face this error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory . i run this project with php -S and without database connection work perfectly. can you help me with this? i setup virtual host for this project but also not working. i also install mysql-server with terminal but no diffrence. running ubuntu 20.04 .

    • @TheCodeholic
      @TheCodeholic  4 года назад

      Check which version of php you have and you need to install php-mysql package by running `apt install php-mysql`

    • @mohammadtaheri98
      @mohammadtaheri98 4 года назад

      @@TheCodeholic Thanks for answering.
      For future reference, you should completely uninstall xampp (lampp) and install php, apache2 and mysql and then you ready to go.
      I found installing guide in DigitalOcean website

    • @RasonYudha
      @RasonYudha 10 месяцев назад

      @@mohammadtaheri98 are you serious?

  • @ilya_123__
    @ilya_123__ 9 месяцев назад

    Thank you!

  • @flavius4021
    @flavius4021 4 года назад

    Interesting video but I dont like the idea of using php in a view file, or generate dynamic html in a php file

  • @alisiraj2100
    @alisiraj2100 4 года назад

    Thanx

  • @armineyvazi9492
    @armineyvazi9492 2 года назад

    hame to bootcamp parashon rikhte

  • @topalek
    @topalek 4 года назад +1

    at last. Maybe you will open the videos every day insted of one video in two days?

    • @geneartista9714
      @geneartista9714 4 года назад +4

      wow man you don`t know how hard it is to make a video without making mistakes, can`t you even be grateful enough that he`s giving a FREE advance lecture about PHP

  • @kevinnacario359
    @kevinnacario359 2 года назад