My dev server is http://localhost/mygreatapp
and my production server is http://www.myawesomesite.com
but maybe someday it will migrate to http://www.myawesomesite.com/mygreatapp
In these cases mygreatapp
is a virtual directory.
I would like a php function to return the correct website roots without having to hard-code anything (e.g., mygreatapp
), regardless if it's off the default website or a virtual directory. In either case, that's where all the relative paths to the files begins.
I have looked at the similar questions and not found a solution that does not involve hard-coding, which would then involve having to update the value for each environment, painful and error prone.