I'm doing a lot of refactoring on a project so it can actually have development branch. Right now, all includes are hard-coded in and it's really messy. A lot of includes will point to the same file, but the includes look very different from each file (and will, by necessity, have to be different for a dev site, also some copying of identical files to different directories for the time being).
I've looked at this answer: StackOverflow: Path of current PHP script relative to document root and tried to implement a
getpath.php with
<?php
define("DIR_BASE", dirname( __FILE__)."/");
define("SERV_CONFIGS", DIR_BASE."server/specific/config.php");
to give me a decent starting spot that can adapt to overall location (as well as a few environment-specific location variables), so that way I could just change every instance of
include ("../../../include/foo.bar");
include ("http://example.com/something/else.php");
include ("../../../server/specific/config.php");
and
include ("../include/foo.bar");
include ("../something/else.php");
include ("http://server/specific/config.php");
and
include ("http://example.com/include/foo.bar");
include ("/something/else.php");
include ("/server/specific/config.php");
etc. all into just
include (DIR_BASE . "include/foo.bar");
include (DIR_BASE . "something/else.php");
include (SERV_CONFIGS);
That way, I can just copy-paste those two lines through the hundreds of files and be done. (it's going to be much more than just three file names).
However, it dawned on me that each page will STILL need to be a bit of "unique snowflake" to include my getpath.php, each one pointing from that individual file to getpath.php to include it.
How can I include getpath.php without making each page have its own snowflake version of include("getpath.php")?