I keep getting confused when trying to include files that will have different paths in a local environment vs production.
For example, I have this in my usercontroller.php file:
require_once(__DIR__ . '/config.php');
On my local host, usercontroller.php is located in www/myproject/inc/ and config.php is in www/myproject/ (the project root directory)
This fails.
All I want is a way to define the projects root. i.e on localhost it's www/projectname and in productions it's / Since files are located inside the projectname directory on my localhost, it's causing issues on my production server.
What is the best way to simply define a base path and build my require_once from that?
i.e. require_once($basePath . 'inc/filename.php'