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

Comments

Milan Bastola says:

It will be best if you put title on each video instead of Numbers. like PHP: Create Your Own MVC – Title Goes Here etc.

노윤태 says:

Very helpful! I gave you thumbs up. Good voice, too.

shaik hanuman says:

@Notorius C Labs
Sir i didnt understand plzz give any idea about this video i am waiting to u r reply sir…

Martin Dufour says:

So helpful, big thanks !

Anneme Asla says:

Standards in this context still pass??

Twiistrz says:

Cannot declare class Error, because the name is already in use

Shreeram Sharma says:

Great tutorial!!! I am a PL trainer, your example helped me a lot to adjust the things quickly. Thank you!!!

Sergey TopalSergey says:

Dude, You are the first developer whose MVC tutorial actually made sense! Liked, subscribed!

david parham says:

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.

LordKamephis says:

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.

n0body says:

So the model is the backend code you write, view a template and controller is just sending information left and right?

NOYB says:

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

Uchiha Itachi says:

Notice: Undefined index: url in libboot.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?

Abhishek Sinha says:

Can you please describe about SourceFile folder, what would in inside that?

Kien Alang says:

Thanks for the tutorial.

MrMendykahan says:

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

Felipe Paz says:

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

Peter Šeliga says:

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

Rup7ur3 Strygwyr says:

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?

Notorius C Labs says:

Thank you so much for sharing your knowledge man, thanks a lot!

Akagha Chinaka says:

Using error in PHP seven as a class name is wrong.

Guilherme Macedo says:

I have a doubt about $controller->($url[1]}();
What it means? A little confused.

Tunde Ajao says:

Great work …. and you made things a lot easier …

Вячеслав Коростин says:

cool!

D I M says:

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

Иван Иванов says:

Can anybody tell me, is it actual now?

Rafael Martins says:

very nice man thanks a lot

avi12 says:

I’ve gone through about 3 different channels that offer an MVC tutorial, but the tutorial in this channel works like a charm!

Amazing NEBSTER says:

it doesnt work on xampp

Ricardo Belmont says:

Is this supposed to be for noobs?

Uzair Vawda says:

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;

Mark Augustine says:

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.

fritz fritz says:

$this->view = new view() is consfusing. where $this->view came from ? calling a global variable without instantiating
it ?

Helge Meiering says:

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:xampphtdocsmvc_austobenmvc_tutindex.php:12 Stack trace: #0 {main} thrown in C:xampphtdocsmvc_austobenmvc_tutindex.php on line 12

I use XAMPP

Muhammad Shehroz says:

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]

Kien Alang says:

Hi there, How to pass the errors from the controller to the view?

illidan155 says:

why: $controller = new $url;
instead of: $controller = new Index();
what is that syntax?

sarath nath says:

Really liked…simply sooperb video…..Any way to get source code of this videos…..

Krawallbruder says:

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

Ty

Anime Reviews says:

If you are getting a 500 error message try adding the following line after RewriteEngine On:
RewriteBase /

John B says:

In case anyone is using xampp nowadays, you can’t name the class Error because you will have a naming collision.

Write a comment

*

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.


Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles▷ Show Cars▷ Motorbikes▷ Scooters▷ Bicycles▷ Rims & Tires▷ Luxury BoatsFashion▷ Sunglasses▷ Luxury Watches▷ Luxury Purses▷ Jeans Wear▷ High Heels▷ Kinis Swimwear▷ Perfumes▷ Jewellery▷ Cosmetics▷ Shaving Helpers▷ Fashion HatsFooding▷ Chef Club▷ Fooding Helpers▷ Coktails & LiquorsSports▷ Sport Shoes▷ Fitness & Detox▷ Golf Gear▷ Racquets▷ Hiking & Trek Gear▷ Diving Equipment▷ Ski Gear▷ Snowboards▷ Surf Boards▷ Rollers & SkatesEntertainment▷ DIY Guides▷ Zik Instruments▷ Published Books▷ Music Albums▷ Cine Movies▷ Trading Helpers▷ Make Money▷ Fishing Equipment▷ Paintball Supplies▷ Trading Card Games▷ Telescopes▷ Knives▷ VapesHigh Tech▷ Flat Screens▷ Tech Devices▷ Camera Lenses▷ Audio HiFi▷ Printers▷ USB Devices▷ PC Hardware▷ Network Gear▷ Cloud Servers▷ Software Helpers▷ Programmer Helpers▷ Mobile Apps▷ Hearing AidsHome▷ Home Furniture▷ Home Appliances▷ Tools Workshop▷ Beddings▷ Floor Layings▷ Barbecues▷ Aquarium Gear▷ Safe Boxes▷ Office Supplies▷ Security Locks▷ Cleaning ProductsKids▷ Baby Strollers▷ Child Car Seats▷ Remote ControlledTravel▷ Luggages & Bags▷ Airlines Seats▷ Hotel Rooms▷ Fun Trips▷ Cruise Ships▷ Mexico Tours