0

I'm (kind of) following this tutorial for MVC from youtube https://www.youtube.com/watch?v=KLEuiLf_hDQ&list=PLfdtiltiRHWGXVHXX09fxXDi-DqInchFD&index=5

And I've got a problem around 3:30. It can't find Home class, BUT if I change his 26th line from

$this->controller = new $this->controller;

to

$this->controller = new Home();

it works perfectly fine. Also, If I

echo $this->controller;

it shows "Home". I have absolutely no idea what went wrong. If it helps I'm using it for a little different project which is using namespaces.

  • 2
    Oh god. That video seems terrible. I would recommend to avoid the entire mess. What that "mvc tutorial" actually deals with is simply URL routing. Which, BTW, is unrelated to MVC as a concept. – tereško Aug 01 '17 at 20:11
  • Where should I look for instructions about routing then? – I hate users Aug 01 '17 at 20:13
  • I am not entirely sure. I made a [post](https://stackoverflow.com/a/19309893/727208) about it some time ago. But if your code is going to production, then I would recommend just using [FastRoute](https://github.com/nikic/FastRoute) or [Symfony's Router](https://symfony.com/doc/current/components/routing.html) and investing the time in exploring composer packages, instead of going the DIY road. And yes, I realize that all 3 of these options are unfit for a complete newbie ... oh well .. off to the deep end. – tereško Aug 01 '17 at 20:17
  • It's for learning in my free time only, using pre-made framework would be easier but I want to know how it works. – I hate users Aug 01 '17 at 20:24
  • 1
    Those two solutions I linked you to are not "frameworks". They are standalone libraries. If your goal is to learn, you can either try to go through the post I linked you to or attempt to back-engineer those two libs. **BTW**, learning how to use composer is an important skill these days. – tereško Aug 01 '17 at 20:26

0 Answers0