How to require file from another folder?
Your about.php
file is located in the controllers
folder. You want to include the views/about.view.php
file according to your code. That means starting from about.php
, you want to include the controller/views/about.view.php
file. This is incorrect because your views folder is not inside the controllers
folder. It is located outside of it.
The correct approach is to go up one level by using ../
. This means starting from your interhub folder, the request should be interpreted as ../views/about.view.php
. So, it starts from the controllers
folder, then goes back one level to the interhub
folder with ../
, and then goes into the views
folder with /views
. After these steps, it will find the about.view.php
file and your code will run correctly.
require_once "../views/about.view.php";
More information - file path
Extra - How to can view errors?
Okay, this file reference is fixed, check! If you receive further 500 error codes, it's definitely not because of this, but rather due to an error in your PHP code. You can output the errors to the screen or view them in the Apache error.log file.
// Show error message instead of "Error 500" blank page.
ini_set('display_errors', 1);
error_reporting(E_ALL);
Warning! Use it exclusively for home development purposes!
In live code, this poses a security vulnerability!