If you have the following error at 56:55 call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\SiteController::handleContact() cannot be called statically You have to make some changes in Router class. During the time of making this framework PHP version was allowing calling non-static method statically, but later it was changed. Here is fix... At 31:07 instead of calling call_user_func($callback) directly, we need to create an instance of the controller first. if (is_array($callback)) { $callback[0] = new $callback[0]; } return call_user_func($callback);
@Đinh Như Khang I also have this type of problem. The temporal solution was to make the function in the controller static. I'm stilling looking of a good fix to work without having to make all controller functions static.
Never worked with a (MVC) framework in my life and your explaination is super clear and easy to comprehend. You have a gift to do this. Keep doing this please.
@@m3awna I'm not a developer. At least not professional. In my spare time I'd like to program. And I did that on and off for the last 20 odd years. Mostly HTML and CSS, a bit of PHP and even less JS.
I am a beginner so I can't judge others' code but I know clean code when I look at one. Readable, organized and it's only the first video. Fantastic work!!
Just finished Part 1. I really learned quite a bit. Some constructive feedback: - Maybe breaking the video down into shorter parts. There were a few points where I felt the video could have ended and a new one started. - For those not using PHPStorm, maybe clarifying when PHPStorm automagically adds something. - Maybe a little less jumping around; can be confusing for novices. Great job and extremely thorough explanation! Thank you!
Holy macaroni, I also created my own framework which is similar to your routing approach, But this is entirely more creative and object oriented, I might as well try this and re write my code. Thanks for this, God Bless you!
@@TheCodeholic not really. It's someone you reach out to for some career advice. Share development process and also, help you become a better developer.
@@TheCodeholic I have finished your course on Traversy Media, and now started this one. It helps a lot. Never seen anybody iterating over one subject like you do. It's simply amazing. I would love to become your acolyte and work for you on daily basis
Thank you buddy. However I am not a genious at all. I am just very hard working person and this framework show also this. I did it 3 times to finally create video on it. But thanks once again... Appreciate your feedback...
Excellent Job! You mentioned that this framework is for educational purposes only. I was wondering what has to be done to make it suitable for production.
thank you very much , building an MVC framework is an awesome way to help people understand how real Frameworks like laravel works under the hood , keep going bro I just start learning backend development .
Very good approach with the evolution step by step ans very well explained, you did a great job congratulation and i hope that you have the courage to continue like this because it's lot of work. Thank you for sharing your knowledge with the community, i follow and and gonna share your channel !!!
Hi everybody! May I ask you a question? On 56:08 when you pass an array with classname and non-static function to 'call_user_func()', how does it work with a class but not an object of this class in passed array? If class is passed it should call method statically, but it is non-static method 'contact' (or 'handleContact')? Thank you))
First of all i want to thank you for this great tutorials, there is one question about call_user_func function because does not accept non static method as second parameter if first parameter is not an instance, and thank you again.
Hi Zura! Thank you so much for the tutorial and for the immense effort behind it! But.. I'm kinda stuck at 56:55min...and i am very confused! How is it that you can call handleContact without the SiteController being instantiated??? Because for me an error is thrown consequently: "Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\SiteController::handleContact() cannot be called statically in... (stack trace)...C:\Users\User\Desktop\Code2022\Custom_MVC_Framework\core\Router.php on line 67"
Very, very nicely done tutorial. Great material. Thanks. Only one thing: You are running toooo fast, way to fast. Its hard to follow if, I am making this project while watching. Really hard to stay on same page. While pausing video every 10seconds is an option, its little hard to keep in mind what and why I was doing 1min ago, so I got to rewind back, making me go through same material again and again. Just slow down a little. Would be amazing. Probably just, me, but still. Thanks for amazing content. Best one I found so far. :) Keep it up.
You have a gifted voice... The way you explained is superb... It's a lot of work a bigg salute to the hard work you have put in. Just one question or point, the ones using Xampp or Wamp will not get the same errors as php built-in server?
In addition it would be great to install sentinel native or having sentinel native installed in any MVC other than Laravel ... in case just an idea... u can carry forward this same MVC integrating it with Twig and Sentinel it would be awesome... We can have Twig in one part and Sentinel in another ...
Apologies by output I mean errors ... Corrected in my comment 😊. There are a few, I would say smart logics you used here ... I tried the codes but Xampp was showing 404 without configuring it .. I am using php 7.4.9 ver Xampp
56:52 I got Deprecated: call_user_func() expects parameter 1 to be a valid callback, non-static method app\controllers\SiteController::handleContact() should not be called statically in C: ginx-1.18.0\www\mvcFramework\core\Router.php on line 39. PHP v. 7.4.9
@@Renodarkholes If you watch the video series till the end, you will see that I delete the core folder and make it reusable composer package. So the final version is definitely without core and is available on my Github.
First of all .. thank you for this great tutorial it was very useful second thing in 56:40 there's an issue in calling 'handle contact' method in the site controller class ... i think the method is been called in a class context while the method hasn't been declared as static . hope to correct me if i'm wrong . thank you :)
Hello The codeholic, this is a very awesome tutorial and thanks very much for it. I just discovered your channel yesterday and quickly made the decision to take this particular framework tutorial, and i have learned a lot of new things already. I have reached 43:08 mins on this video but my browser doesn't show any content at that point. I am running php 7.4.21 and apache on ubuntu 20.04. any hint on what might be causing it would really help. Thanks one more time.
Hi. When using the handleContact method from the SiteController class I get the warning that handleContact should be called statically. Can you help me with this? When I make the method static the warning goes away.
I'm currently at time stamp 31:54, am using xampp, Firefox and VS Code. I have tried adding 'users' to the URL, and received 'Object Not Found' error. At this point, when I navigate to the public/index.php file, 'Not Found' is displayed, and not 'Hello World.' Any thoughts on this? Thanks.
If you are using xampp you have to setup virtual host. If you want to follow the tutorial I advice to start the server using php -S. And only switch to apache virtual host later...
If i dump the routes array in the router->resolve function, I get '/' and 'home' and '/contact' and 'contact'. When the $callback = $this->routes[$method][$path] line is run, the array does not have a method stored, so $callback is false.
Thank you very much sir 👍😊😊😊😊😊😊😊😊😊😊😊😊😊😊 very informative this is type of teaching we are expecting. In one hour we are doing coding very interesting and exciting thanks for providing great lectures.
Hey, Zura, this project is awesome! You have done a great job. But one thing I would like to the project. Would be cool if the video was splitting into chunks which may observe on GitHub. Now if go on GitHub you see the eventual result. Excuse me for my insolence. THANK YOU for worry about a beginers. А project like this so few on the internet.
Hmmm, I'm downloaded your project and by switching among commit of the project I found a point that I want to see in the video. Would be good if you add the timing of the video into the commits on GitHub.
Your PHP version may be low version. Should be a minimum 7.4 If your php version is greater than 7.4 and you still get this error; Windows + S > write Edit the System Environment variables > System Environment variables > Edit the 'Path' in user variables and system variables. Your PHP version may not be up to date. Here you add the current version
Thank You very much! It's very helpful ☀️👍 Also I have a one question. Why we need a function setLayout in Controller if we can use variable $layout for function of Router - layoutContent?
56:30 please, how to call class method while neither the class has instance nor the method is static?? I tried it and it doesn't work, I really don't know how it works here!
Hi!! Great tutorial!!! I've a problem with the code. The code stucks with an error 500. I'm currently at timestamp 55:55 127.0.0.1:48408 [500]: GET / - Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, function "App\Controllers\SiteController" not f ound or invalid function name in /home/nhytros/localweb/mwd_framework/app/Core/Router.php:38 Line 38 says: return call_user_func($callback); How can I fix this?
great job, i find it easy to do whatever i want with this framework. I have issues identifying if the framework used is laravel or yii2 or any other. I am new to programming and i will appreciate you to clarify this for me. Thanks
I dont know why but I keep getting error in good version from this code call_user_func($fn); Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\MainController::create() cannot be called statically in but if I changed it to var_dump it turns out fine which leads to not calling the controller. Please help guys
I got to know you through freecodecamp on a course posted PHP MVC Framework, the course was so great and here I am on your channel and everything you've been posting was great and easy to learn. Thank you for the great work you've been putting into this. I tried integrating bootstrap with composer require tubs/bootstrap instead of the CDN linking, after everything was downloaded into the vendor folder I linked it in the layout folder main.php but it's not working out. Any help on this, please?
some one assist me, I can get past 49:01. post method don't seem to be working $app->router->post('/contact', function (){ return 'handling submited data'; }); When I remover post method, everything works fine.
Hello codeholjc, I solved the problem, it turned out I had mispelt the post method . Thanks for the reply and the good work you are doing teaching the whole world
If you are following along and got this error: Uncaught TypeError: call_user_func(): Argument #1 ($ca llback) must be a valid callback, non-static method app\cont rollers\SiteController::handleContact() cannot be called statically in /opt/xampp/htdocs/phpMvc/core/Router.php:43 Stack trace: change: [new SiteController::class, 'handleContact'] to: [new SiteController(), 'handleContact']
It's been so long ago since I worked with PHP, I vaguely remember I did this routing with a .htaccess file, but either I was doing it wrong back then, or a better way has arrived?
great tutoriel it helps me a lot and took me one day to understand and test all things. I found just one error and i know it will be mentionned in the next videos. In the last video the _404 page not found dosen't work because in the layoutContent method we try to access to the propriety controller of the Application and it's not initialized ($callback null).
the problem with exiting framework is they are not based on domain driven design, one example of concerns is, they load view classes and other dependencies related to text/html for application/json requests. they executes a lot of defaults that not going to be needed for outputting the reply. imagine having access to title for json request.
Can someone help me? I'm using mamp, and I have to have a file htaccess in order to redirect to index everytime I type something that shows me not found... So without htaccess my router.php does not work because the request dont go to index.php, is there any other way or htaccess files are mandatory? Because I see that He does not need It... and in his git files, there's no htaccess file... so that means if he uploads the files to a webserver that will work without problem? Tyvm
Hi and many thanks to you. I got a question regarding comments. which plugin do you use to generate comments automatically? ant the comments follow psr standards am I right?
If you have the following error at 56:55
call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\SiteController::handleContact() cannot be called statically
You have to make some changes in Router class. During the time of making this framework PHP version was allowing calling non-static method statically, but later it was changed.
Here is fix...
At 31:07 instead of calling call_user_func($callback) directly, we need to create an instance of the controller first.
if (is_array($callback)) {
$callback[0] = new $callback[0];
}
return call_user_func($callback);
Does your controller have correct namespace?
Try to put \ in front of app\controller\SiteController
@Đinh Như Khang I mean in index.php
You have something wrong in either index.php or in SiteController
@Đinh Như Khang I also have this type of problem. The temporal solution was to make the function in the controller static. I'm stilling looking of a good fix to work without having to make all controller functions static.
This solution works perfectly fine. Tested and it's working.
Three years later, it remains a great contribution to the community!
Thanks for all
Never worked with a (MVC) framework in my life and your explaination is super clear and easy to comprehend. You have a gift to do this. Keep doing this please.
Huge thanks man. APPRECIATE
how long have you been a developer?
@@m3awna I'm not a developer. At least not professional. In my spare time I'd like to program. And I did that on and off for the last 20 odd years. Mostly HTML and CSS, a bit of PHP and even less JS.
@@m3awna I started coding 10 years ago and it's almost 9 years I work as a developer.
@@TheCodeholic we entered this field around the same time, but you're doing a lot better than me :) thanks for the tuts
i think this is the best php tutorial for building MVC FRAMEWORK
I am a beginner so I can't judge others' code but I know clean code when I look at one. Readable, organized and it's only the first video. Fantastic work!!
Thank you, I did not even need to increase the playback speed because the narration is on point!
Thanjs buddy
Just finished Part 1. I really learned quite a bit.
Some constructive feedback:
- Maybe breaking the video down into shorter parts. There were a few points where I felt the video could have ended and a new one started.
- For those not using PHPStorm, maybe clarifying when PHPStorm automagically adds something.
- Maybe a little less jumping around; can be confusing for novices.
Great job and extremely thorough explanation! Thank you!
Y u didn't have more viewssss! Just discovered your channel and immediately subscribed. Please continue the hard work, you're amazing.
Thanks buddy
Holy macaroni, I also created my own framework which is similar to your routing approach, But this is entirely more creative and object oriented, I might as well try this and re write my code. Thanks for this, God Bless you!
Thanks buddy
This is crazy amazing. I never knew PHP was this cool. Thank you. Thank youuuuuuuuuuuuuuu
You're very welcome! PHP is very cool language.
@@TheCodeholic Thank you. Do you offer mentorship? That's one thing I am missing in my career development
Do you mean one to one teaching?
@@TheCodeholic not really. It's someone you reach out to for some career advice. Share development process and also, help you become a better developer.
I do this for junior developers in my company. And I plan to express this on my youtube channel.
i am not an english speaker but i learned so much with this video, thanks :D.
Glad to hear that!
Lots of thanks. Is something i have been looking for for years
Welcome buddy
Hello,
I'm Vietnamese, I've watched your video and I see your video is very good, there's a lot of PHP stuff that I don't know yet.
Thank you for your hard work sir! This could definetely be a paid course. One more time, hats off to you sir, and a million thanks.
Thanks buddy.
It means a lot for me.
@@TheCodeholic I have finished your course on Traversy Media, and now started this one. It helps a lot. Never seen anybody iterating over one subject like you do. It's simply amazing. I would love to become your acolyte and work for you on daily basis
I knew that accent sounded familiar, and then the surname appears! Great tutorial. Madloba!
Thanks buddy.
Shenc madloba 😉
Hats off ❤️❤️❤️
Love from 🇮🇳 India.
You are really a genius.
I want to give you thumbs-up as many as I can.
Thank you buddy.
However I am not a genious at all. I am just very hard working person and this framework show also this.
I did it 3 times to finally create video on it.
But thanks once again...
Appreciate your feedback...
1:01:30 why you didn't use extract() instead of $$? Is there any cons?
I think $$ is easier to use. I do not know TBH if there is any cons.
Than I believe this code is
extract($params)
easier than this :D
foreach($params as $key => $value){
$$key = $value;
}
don't you think so?
I think you are right.
Just I have not used that before.
@@TheCodeholic you taught me something, I taught you something :) thanks for exchange.
Thanks.
Thank you a lot!. After 3 times i watched and workout this lesson i begin to understand! Lets go ahead! Your lessons is great!
Excellent Job! You mentioned that this framework is for educational purposes only. I was wondering what has to be done to make it suitable for production.
It needs to be tested, bug fixed and improved for next several months only after that I would say it would be ready for production
@@TheCodeholic Can you make a video on how to test and bug fix software for production development. BTW, nice video.
Excellent, thanks, please make lectures on Laravel framework, if you have time 👍
Ya i am too looking forward for that
thank you, i think this is the best php tutorial for building MVC FRAMEWORK
The way you code is very nice and understandable. Thanks a lot
Thanks a lot buddy.
thank you very much , building an MVC framework is an awesome way to help people understand how real Frameworks like laravel works under the hood , keep going bro I just start learning backend development .
it is a gold material thanks for sharing it on youtube for free you are great man
Very good approach with the evolution step by step ans very well explained, you did a great job congratulation and i hope that you have the courage to continue like this because it's lot of work. Thank you for sharing your knowledge with the community, i follow and and gonna share your channel !!!
Huge thanks Sevdin. Such comments are what I am doing all this for. The more such comments I see the bigger will be my motivation.
Your're a great developer and...a very good teacher. Thanks a lot for sharing so much knowledge! It saved me weeks of reading and testing ;-)
you deserve a subscribe ... Thankyou for this amazing tutorial
This lesson was outstanding. It is the single best example of how to implement OOP in PHP that I've seen.
I am super happy to hear that. Thank you.
Wow!😍😍 Thank you millions for making the series! 🙏🙏
You're so welcome!
It's amazing the way you explain, thank you for this tutorials and for the time spent in creating this piece of art.
Huge thanks
Hey, thanks for the tutorials! Its really give me deep insight on how most of the framework actually work!
good job man, everything in order. very clear and perfect
Thanks buddy
thank you very much from Turkey
You are welcome from Georgia.
Hi everybody! May I ask you a question? On 56:08 when you pass an array with classname and non-static function to 'call_user_func()', how does it work with a class but not an object of this class in passed array? If class is passed it should call method statically, but it is non-static method 'contact' (or 'handleContact')? Thank you))
yes i have the same question, I don't get why can he call it as static method when is not
@@user-cl6zn6sc2k Same question here
For php8 may refer here php.watch/versions/8.0/non-static-static-call-fatal-error
Thank you so much for this content, the way you explain is very understandable
Thanks a lot
It’s really great tutorial. Go ahead sir..❤❤
Thanks buddy
The most greatest work....thanks bro your knowledge is awesome
Thank you
Thank you for this great tutorial.
It was never too late to learn again Thank you so much for the absolute tutorial you have been making❤️❤️ keep up the good work
You are so welcome!
thank you, very helpful and very neat and structured like a laravel router
Thanks buddy
@@TheCodeholic You are welcome, friend
Porra !! Eu esperei por este conteúdo há muito tempo, e agora chegou na minha cara!!
Excellent!!! Hope it will teach you something.
thank you so much .. it is an awesome series
Router is pronounced "rauter", or "ruter", but not "roter". Excellent tutorial. Thank you.
"instead" is pronounced "insted", not "instid".
You are amazing dude, solid stuff.
01:00:54 you can also use PHP's 'extract' function, it basically does the same thing but it is cleaner.
Thanks.
awesome, extract() function is a handy one, thanks, I learnt a new function
using extract is recommended against when dealing with data that could come from an untrusted source
Thank You, your explanation was very understandable
ofc i subscribe to you budy ! i like the way you explain keep up hero !!!!!
Thanks a lot
Glad I found this 👍👍👍
thanks for this great course 👌👌🔥
Very useful! Thank you.
wow so good thank's a lot bro
Keep it going buddy u helped a lot.
Thanks you friend
First of all i want to thank you for this great tutorials, there is one question about call_user_func function because does not accept non static method as second parameter if first parameter is not an instance, and thank you again.
its really grate, So much helpful.
Hi Zura!
Thank you so much for the tutorial and for the immense effort behind it!
But..
I'm kinda stuck at 56:55min...and i am very confused!
How is it that you can call handleContact without the SiteController being instantiated???
Because for me an error is thrown consequently:
"Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\SiteController::handleContact() cannot be called statically in... (stack trace)...C:\Users\User\Desktop\Code2022\Custom_MVC_Framework\core\Router.php on line 67"
Thank you.
I created pinned comment on the video, which explains the problem and what should be done to fix it.
Amazing tutorial, you just got new subscriber today.
Thanks and welcome
Very, very nicely done tutorial. Great material. Thanks. Only one thing: You are running toooo fast, way to fast. Its hard to follow if, I am making this project while watching. Really hard to stay on same page. While pausing video every 10seconds is an option, its little hard to keep in mind what and why I was doing 1min ago, so I got to rewind back, making me go through same material again and again. Just slow down a little. Would be amazing. Probably just, me, but still. Thanks for amazing content. Best one I found so far. :) Keep it up.
this problem is very common amongst tubers. videos are designed for native english speakers.
when learning, speed should not be priority.
@@TomiBorchert yes. I Agree posted comment 1 year ago. Still following channel. Really useful information here. Thank you. :)
Just play it at half speed in the RUclips settings
WoW😘😘, Loved it..👍👍
Thanks a lot 😊
Veri great tutorial🎉❤ thanks a kot
İf possible could you tell me what is your choice?
Laravell or your mvc routing?
This is amazing, thank you
Amazing course, I am learning a lot of thins from your videos ____
Thanks a lot
You have a gifted voice... The way you explained is superb... It's a lot of work a bigg salute to the hard work you have put in.
Just one question or point, the ones using Xampp or Wamp will not get the same errors as php built-in server?
In addition it would be great to install sentinel native or having sentinel native installed in any MVC other than Laravel ... in case just an idea... u can carry forward this same MVC integrating it with Twig and Sentinel it would be awesome... We can have Twig in one part and Sentinel in another ...
Thanks buddy.
Yes they will have the same output on xampp installation.
Apologies by output I mean errors ... Corrected in my comment 😊.
There are a few, I would say smart logics you used here ... I tried the codes but Xampp was showing 404 without configuring it .. I am using php 7.4.9 ver Xampp
amazing video man.
Thanks
56:52 I got Deprecated: call_user_func() expects parameter 1 to be a valid callback, non-static method app\controllers\SiteController::handleContact() should not be called statically in C:
ginx-1.18.0\www\mvcFramework\core\Router.php on line 39. PHP v. 7.4.9
By the end of the video I have changed the code and don't call the function statically any more...
Check the final version of the code
@@TheCodeholic I have the same problem but I don't find the final version of the code. On Github, the core folder is missing
@@Renodarkholes If you watch the video series till the end, you will see that I delete the core folder and make it reusable composer package. So the final version is definitely without core and is available on my Github.
@@sekhniashvili Ok Thank you for your videos, I like ;-)
it will solve the issues
if(is_array($callback)){
return call_user_func([new $callback[0], $callback[1]]);
}
First of all .. thank you for this great tutorial it was very useful
second thing in 56:40 there's an issue in calling 'handle contact' method in the site controller class ... i think the method is been called in a class context while the method hasn't been declared as static .
hope to correct me if i'm wrong .
thank you :)
Yes. How to fix this? I got stuck here.
@@ThePancakeJedi yo can add static keyword in method declaration
@@ThePancakeJedi You can do this $app->router->post('/contact', [(new SiteController), 'handleContact']);
Hello The codeholic, this is a very awesome tutorial and thanks very much for it. I just discovered your channel yesterday and quickly made the decision to take this particular framework tutorial, and i have learned a lot of new things already. I have reached 43:08 mins on this video but my browser doesn't show any content at that point. I am running php 7.4.21 and apache on ubuntu 20.04. any hint on what might be causing it would really help. Thanks one more time.
use echo instead of return. Return is not showing messages on me
I know its late but try to put echo before $this->router->resolve in Application.php
Awesome course! Your code is clear, and practically explains itself!
It kinda looks like you're implementing the Node & Express way in PHP?
I guess slim PHP framework implemented something like that
Thanks
Hi. When using the handleContact method from the SiteController class I get the warning that handleContact should be called statically. Can you help me with this? When I make the method static the warning goes away.
❤❤❤❤❤ thank you a lot))
Welcome
Amazing tutorial
0:36 why it's not recommended to use in products or websites ?
Great Tutorial. On 1.01 why not use extract($params)
Oh my this earns my sub
I'm currently at time stamp 31:54, am using xampp, Firefox and VS Code. I have tried adding 'users' to the URL, and received 'Object Not Found' error. At this point, when I navigate to the public/index.php file, 'Not Found' is displayed, and not 'Hello World.' Any thoughts on this? Thanks.
If you are using xampp you have to setup virtual host.
If you want to follow the tutorial I advice to start the server using php -S. And only switch to apache virtual host later...
If i dump the routes array in the router->resolve function, I get '/' and 'home' and '/contact' and 'contact'. When the $callback = $this->routes[$method][$path] line is run, the array does not have a method stored, so $callback is false.
Probably you have something differently
@@TheCodeholic by virtual host, are you referring to something different than the Apache server on the Xampp control panel?
at your cmd:
- cd 'your public folder path'
- php -S localhost:8080
at your web server type:
localhost:8080
Thank you very much sir 👍😊😊😊😊😊😊😊😊😊😊😊😊😊😊 very informative this is type of teaching we are expecting. In one hour we are doing coding very interesting and exciting thanks for providing great lectures.
Thank you Shaik,
Glad to read such comments...
@@TheCodeholic I am prodly say your my teacher.
Hey, Zura, this project is awesome! You have done a great job. But one thing I would like to the project. Would be cool if the video was splitting into chunks which may observe on GitHub. Now if go on GitHub you see the eventual result. Excuse me for my insolence. THANK YOU for worry about a beginers. А project like this so few on the internet.
Hmmm, I'm downloaded your project and by switching among commit of the project I found a point that I want to see in the video. Would be good if you add the timing of the video into the commits on GitHub.
Thanks a lot for the tutorial! I'm learning a lot. I had one question, how do I add those comments at the top when generating the classes? Thank you.
You need to open phpstorm settings, find file templatea there and change it.
17:28 what happen?
Parse error: syntax error, unexpected 'Router' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Your PHP version may be low version. Should be a minimum 7.4
If your php version is greater than 7.4 and you still get this error;
Windows + S > write Edit the System Environment variables > System Environment variables > Edit the 'Path' in user variables and system variables. Your PHP version may not be up to date. Here you add the current version
Thank You very much! It's very helpful ☀️👍
Also I have a one question. Why we need a function setLayout in Controller if we can use variable $layout for function of Router - layoutContent?
Well done!
56:30
please, how to call class method while neither the class has instance nor the method is static??
I tried it and it doesn't work, I really don't know how it works here!
@Raymond Bitterling
Actually I don't remember how I solve it exactly, but I think I used static keyword.
@Raymond Bitterling
may you mention the episode or the timestamp in which he did it?
I revised my project and I did use static keyword
This is so good
It is correct if we renderView from the Response class?
Very nice video! One improvement would be to put the timestamps in the description, so one can rewatch one aspect :)
You are right.
Did you create .htaccess? Because index.php is not serve when I typed /users it is showing page not found
He is using the built-in php web server. .htaccess is for Apache.
Hi!! Great tutorial!!!
I've a problem with the code. The code stucks with an error 500. I'm currently at timestamp 55:55
127.0.0.1:48408 [500]: GET / - Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, function "App\Controllers\SiteController" not f
ound or invalid function name in /home/nhytros/localweb/mwd_framework/app/Core/Router.php:38
Line 38 says: return call_user_func($callback);
How can I fix this?
Fixed... solution is at 1:05:00. Sorry :)
Thanks for posting this awesome video which is really help me. But I wonder how to replace if there are 2 or more placeholders in views?
Recommend modeling this with UML so the viewers can get a basic understanding of the structure and flow of requests through the app/
сразу лайк, неглядя ))
great job, i find it easy to do whatever i want with this framework. I have issues identifying if the framework used is laravel or yii2 or any other. I am new to programming and i will appreciate you to clarify this for me. Thanks
It is not Laravel or yii2. It is new framework created to help you understand how frameworks work.
I dont know why but I keep getting error in good version from this code
call_user_func($fn);
Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method app\controllers\MainController::create() cannot be called statically in
but if I changed it to var_dump it turns out fine which leads to not calling the controller. Please help guys
1:03:38
I got to know you through freecodecamp on a course posted PHP MVC Framework, the course was so great and here I am on your channel and everything you've been posting was great and easy to learn. Thank you for the great work you've been putting into this.
I tried integrating bootstrap with composer require tubs/bootstrap instead of the CDN linking, after everything was downloaded into the vendor folder I linked it in the layout folder main.php but it's not working out. Any help on this, please?
some one assist me, I can get past 49:01. post method don't seem to be working
$app->router->post('/contact', function (){
return 'handling submited data';
});
When I remover post method, everything works fine.
Can you provide more information? Or the whole repository?
Hello codeholjc, I solved the problem, it turned out I had mispelt the post method .
Thanks for the reply and the good work you are doing teaching the whole world
If you are following along and got this error:
Uncaught TypeError: call_user_func(): Argument #1 ($ca
llback) must be a valid callback, non-static method app\cont
rollers\SiteController::handleContact() cannot be called statically in /opt/xampp/htdocs/phpMvc/core/Router.php:43
Stack trace:
change:
[new SiteController::class, 'handleContact']
to:
[new SiteController(), 'handleContact']
Works like a charm.. Thank you..
It's been so long ago since I worked with PHP, I vaguely remember I did this routing with a .htaccess file, but either I was doing it wrong back then, or a better way has arrived?
great tutoriel it helps me a lot and took me one day to understand and test all things. I found just one error and i know it will be mentionned in the next videos. In the last video the _404 page not found dosen't work because in the layoutContent method we try to access to the propriety controller of the Application and it's not initialized ($callback null).
the problem with exiting framework is they are not based on domain driven design, one example of concerns is, they load view classes and other dependencies related to text/html for application/json requests. they executes a lot of defaults that not going to be needed for outputting the reply. imagine having access to title for json request.
Can someone help me?
I'm using mamp, and I have to have a file htaccess in order to redirect to index everytime I type something that shows me not found... So without htaccess my router.php does not work because the request dont go to index.php, is there any other way or htaccess files are mandatory? Because I see that He does not need It... and in his git files, there's no htaccess file... so that means if he uploads the files to a webserver that will work without problem? Tyvm
There's a solution for that using htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?path=$1 [NC,L,QSA]
You need to put that where your index is located
Hi and many thanks to you. I got a question regarding comments. which plugin do you use to generate comments automatically? ant the comments follow psr standards am I right?