Many thanks for your time (while I was sleeping)!
@Davo, my understanding is that one can set a $CFG->dirroot, but since Moodle 2.x it will be ignored!
- what a short and sweet trouble ticket!
Thanks for the correction - PHP dirname() and __DIR__. So the short answer is, since Moodle 2.x no point in setting a $CFG->dirroot.
But there is hope, what I wanted to might work without a (forced) dirroot. Need to do some testing.
@Ken, the Why? I was trying to find the best answer for a support enquiry (and learning on the way). The scenario requires a fleet of very small Moodle instances, kind of low cost create and delete Moodle sites. Reminded me of a trick some installers do, keep one code directory and separate the database
and moodledata by checking the HTTP_HOST web server
(in this case Nginx) variable.
I know, I know, Docker is the answer. This is a low profile, low prio enquiry. Paradigm changes can wait.
@all, I know that short-cut breaks PHP CLI scripts. Apart from that was there a security issue?