Loading...

PHP: Create Your Own MVC (Part 1)

PHP: Create Your Own MVC (Part 1)
Patreon | https://www.patreon.com/jream

Follow on Twitter @ https://twitter.com/jreamdev

In this PHP OOP/OOD Tutorial Ill teach you how you can create a very simple, lightweight MVC. This tutorial covers creating an MVC PHP application and the bare essentials. Create PHP MVC.

Get Code @ http://jream.com/lab

RRelated Posts

PHP: Create Your Own MVC (Part 2)

Patreon | https://www.patreon.com/jream Premium Full Courses @ http://jream.com MVC Playlist @ http://www.youtube.com/playlist?list=PL7A20112CF84B2229&feature=view_all In this PHP MVC Tutorial

PHP: Create Your Own MVC (Part 3)

Patreon | https://www.patreon.com/jream MVC Playlist @ http://www.youtube.com/playlist?list=PL7A20112CF84B2229&feature=view_all In this tutorial we make some changes and create a login form with a

PHP: Create Your Own MVC (Part 4)

Patreon | https://www.patreon.com/jream MVC Playlist @ http://www.youtube.com/playlist?list=PL7A20112CF84B2229&feature=view_all We do some XHR (AJAX) Calls within our MVC. If you need help here are

What is programming MVC? [Detailed Explanation]

Have you ever wondered what MVC means in programming or how it really works? MVC stands for Model, View, Controller, and it is an architectural paradigm used by many web frameworks such as Ruby on

Why I Left My $100,000+ Job at Google

Here’s why I left Google and why I am NOT following my passion! :P Keep in touch on Facebook: https://www.facebook.com/entercsdojo Support me on Patreon: https://www.patreon.com/csdojo My

CComments

  • Jake Stone
    Hi, I noticed an oddity if I just go to the root, i get a "url not set" (of course), but anything else in the url works as it should, how would it make it if someone goes to the root, it will send it to index?

    So I have to check to see if url is set, then "get" it, if not, I have to hard set it.

    Sounds like something in the conf file is not working just right. any idea?
  • Shreeram Sharma
    Great tutorial!!! I am a PL trainer, your example helped me a lot to adjust the things quickly. Thank you!!!
  • Amazing NEBSTER
    it doesnt work on xampp
  • MrMendykahan
    Hi thank you very much for the videos are really enjoyed them. I followed PHP MVC one and I'm currently in middle of the 2nd. However when I call the JavaScript files, it returns them but the content is whatever is displaying on the page. Basically they would be an error in the console when I click on the JavaScript page it will show text for example it would say this is there error view. When I put in the complete URL for the JavaScript file I just get the error page. In other words it is trying to render a neural and putting in and because it doesn't make sense to the render it's just returning the error class
  • Krawallbruder
    Youre including files based on the URI thats absolutely against all rules of MVC!!! MVC was created to avoid those traps! Nobody wants unknown visitors to control what files are included!
  • Intec Hesed
    Ty
  • sarath nath
    Really liked...simply sooperb video.....Any way to get source code of this videos.....
  • Guilherme Macedo
    I have a doubt about $controller->($url[1]}();
    What it means? A little confused.
  • Kien Alang
    Hi there, How to pass the errors from the controller to the view?
  • Martin Dufour
    So helpful, big thanks !
  • Kien Alang
    Thanks for the tutorial.
  • Keval Gajjar
    No one can learn from your videos because your are not explaining the tag and etc. you are just speaking that you are writing. 😡😡😡
  • Sergey TopalSergey
    Dude, You are the first developer whose MVC tutorial actually made sense! Liked, subscribed!
  • 노윤태
    Very helpful! I gave you thumbs up. Good voice, too.
  • Rafaa Ferid
    really i'm thankful for this tutorial but i wish that you used routing.php instead of .htaccess so if you can make a tutorial for that i'd be happy
  • illidan155
    why: $controller = new $url;
    instead of: $controller = new Index();
    what is that syntax?
  • shaik hanuman
    @Notorius C Labs Sir i didnt understand plzz give any idea about this video i am waiting to u r reply sir...
  • Notorius C Labs
    Thank you so much for sharing your knowledge man, thanks a lot!
  • Abhishek Sinha
    Can you please describe about SourceFile folder, what would in inside that?
  • D I M
    hi admin. I have followed and completed your MVC tutorial. are there any tutorials you can share again for pagination with mvc?
    please help you
  • Samuel Anthony
    Please the t video is fast... well i understood it though and you type fast...
  • Uzair Vawda
    For some reason, $url = $_GET ['url']; isnt working for me. I had to use $url = $_SERVER['REQUEST_URI']; which works. Also, when I run the project with the index extension, I never get the "we are in index" eventhough i am requiring the contollers.
    require 'controllers/' . $url . '.php';
    $controllers = new $url;
  • Uzair Vawda
    Does anyone know if there is an updated version of this series? It is very informative but quite old.
  • Вячеслав Коростин
    cool!
  • Tunde Ajao
    Great work .... and you made things a lot easier ...
  • Muhammad Shehroz
    This is how .htaccess works
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([a-zA-Z0-9-]+)$ index.php?uri=$1 [QSA,L]
  • Иван Иванов
    Can anybody tell me, is it actual now?
  • Milan Bastola
    It will be best if you put title on each video instead of Numbers. like PHP: Create Your Own MVC - Title Goes Here etc.
  • Akagha Chinaka
    Using error in PHP seven as a class name is wrong.
  • Felipe Paz
    Fatal error: Cannot declare class Error, because the name is already in use in /opt/lampp/htdocs/mvc/controllers/error.php on line 3

    Does anybody had this error?

    I solved it changind the class name Error by Erro
  • Helge Meiering
    thank you for this tutorial.

    I have a problem :).

    I coded until to minute 4 exactly the same. When I'll try it, it will comes 'Class not found index bla'. Why? I get the content of the URL, but not the contet of the class Index. Ok, my folder calls controller and not controllers.

    Fatal error: Uncaught Error: Class 'index' not found in C:\xampp\htdocs\mvc_austoben\mvc_tut\index.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\mvc_austoben\mvc_tut\index.php on line 12

    I use XAMPP
  • Anime Reviews
    If you are getting a 500 error message try adding the following line after RewriteEngine On:
    RewriteBase /
  • avi12
    I've gone through about 3 different channels that offer an MVC tutorial, but the tutorial in this channel works like a charm!
  • fritz fritz
    $this->view = new view() is consfusing. where $this->view came from ? calling a global variable without instantiating
    it ?
  • Rafael Martins
    very nice man thanks a lot
  • Peter Šeliga
    Hello, I`d like to ask a question. How is it possible that one can require file like 'views/...' from within the 'View.php' file? Why isn`t it necessary to do it like this '../views/...'?
    Thanks for response
    (and sorry for my English if there are any mistakes) :)
  • NOYB
    Hi, just wanted to say thank you very much for this. This is the first tutorial about MVC with PHP that I actually understand!! Amazing work!!
  • Intellect
    So even if i am Ukrainian, i understand MVC pattern at this one video better than on the 100 ours videos. Thank a lot of man//// sorry for my English))
  • Mark Augustine
    When I try to modify something in the default.css, nothing happened. I mean, the previous styles, bgcolor, font-size, etc, everything is still the same, however, when I try to change it, it no longer changes. You have any solution to this problem? Thank you.
  • John B
    In case anyone is using xampp nowadays, you can't name the class Error because you will have a naming collision.
  • Ricardo Belmont
    Is this supposed to be for noobs?
  • Twiistrz
    Cannot declare class Error, because the name is already in use
  • Blaireswip
    swip
  • Wanipiro Aji
    Whould you like to continue the tutorial, please ?
    I'm waiting for the next part of it.

    I think it will be a perfect MVC (framework) and the very famous one, becouse it's very easy to understand.

    I very like it, but please make the framework to become more mature.
    I like codeigniter, but I prefer to use yours if you continue develop it and make the documentation by video.

    Becouse, i feel the really opensource framework from yours.

    Thanks a lot for your video tutorials.
  • david parham
    i am very much appreciating your vids! still working with them. you make quick, sensible work out of it. btw, must you define $arg=false as the argument, for the URL [ex, 10] to be passed in and used in the function? regardless, yours works so that is good enough so far.

    also, am i the only one on the planet who wants it to be "left slash" and "right slash"? also, when you say "back slash" it sounds like you mean the slash leaning to the left. that is why i like my convention of left and right. every nation understands left and right, more than back and forward, yes? also, left and right is fewer syllables. anyway, thx, jReam for ur vids.
  • n0body
    So the model is the backend code you write, view a template and controller is just sending information left and right?
  • Anneme Asla
    Standards in this context still pass??
  • Uchiha Itachi
    Notice: Undefined index: url in \lib\boot.php on line 6

    Any Ideas?
    Thanks !

    P.S :

    How viable is this to use tutorial to use for personal long term framework these days?
  • Rup7ur3 Strygwyr
    I have a problem using this combined with .css / .js etc.

    Lets say I have style.css inside a css folder in my root directory. There is also a file named .htaccess inside the css folder which turns RewriteEngine off.

    If I browse to: *website.com/index*
    It goes perfectly fine to: *website.com/index.php?url=index* (internally)
    There is no problem there since it still goes to: *website.com/css/style.css*

    Yet, if I browse to: *website.com/index/test*
    It goes to perfectly to: *website.com/index.php?url=index/test* (internally)
    However, now the css link is broken: *website.com/index/style.css*

    Is there a way to fix this?
  • LordKamephis
    How can I reset a view.. If I call a controller, the main view of this controller is rendered in the constructor. I want to call a function for a different view, but the constructor renders the main controller of this view.