0

On my Synology (linux) server I have set-up three Apache2.4 / PHP web environment with the roots being:

/volume1/web
/volume1/webDevZone
/volume1/webTstZone

I would like to have a mechanism where I can call something like echo $_SERVER [DOCUMENT_ROOT] and get / regardless what environment I am running on. This way when I can call includes or require without needing to change things as I move my application from one environment to the other.

Unfortunately, _ DIR _ does not do the trick as it does not returns / (the desired result). Instead it returns the full path of a file. So if the file is nested a few levels, then _ DIR _ returns all levels.

I'm thinking that the solution would not be a PHP one, but rather an Apache one.

I was hoping that open_basedir do it, but it doesn't seem so.

Any idea?

Thanks

QuesnelJ
  • 35
  • 6
  • 2
    Does this answer your question? [Get Root Directory Path of a PHP project](https://stackoverflow.com/questions/8668776/get-root-directory-path-of-a-php-project) – Kaleb W Apr 12 '20 at 03:09
  • Thanks for your reply, but unfortunately it does not help me. I have updated the question with more details. Thank you. – QuesnelJ Apr 13 '20 at 13:50
  • `open_basedir` is for limiting PHPs access to files outside of its environment. Why doesn't `$_SERVER['DOCUMENT_ROOT']` do what you want it to do? – MatsLindh Apr 13 '20 at 14:05
  • Well, I suppose I can work with DOCUMENT_ROOT. But I was hopping to hide the root. This way I could just start my includes with "/blah/blah/file.inc" without prefixing it with anything. – QuesnelJ Apr 14 '20 at 19:38

0 Answers0