PHP for Beginners - Ep. 15 PHP router issues
Hello everyone, I am currently working through the PHP for beginners series and I am encountering the following error:
Warning: require(views/index.view.php): Failed to open stream: No such file or directory in /Users/kdarel/websites/demo/controllers/index.php on line 5
Fatal error: Uncaught Error: Failed opening required 'views/index.view.php' (include_path='.:/opt/homebrew/Cellar/php/8.3.12/share/php/pear') in /Users/kdarel/websites/demo/controllers/index.php:5 Stack trace: #0 {main} thrown in /Users/kdarel/websites/demo/controllers/index.php on line 5
To me, it seems like this is telling me that it can't find the 'views/index.view.php' file when it is required in the controllers/index.php file, which would make sense because we are further into the directory tree at this point in the controllers directory and we need to move up one directory to the views directory. But, even if I change the require statement to be require '../views/index.view.php' I still receive the error.
If I manually specify the route in the address bar such as "/" or "/about" I am able to access each page but if I attempt to access them from the Home page using nav buttons, I get the above error.
I have not yet completed the episode because I can't seem to get past the error, but I have compared my source code to that which Jeffrey posted on Github and all files appear to be identical for what I have completed up to this point. Does anyone have any ideas?
Thanks in advance, Kevin
Please or to participate in this conversation.