1
0
Fork 1

Merge pull request 'Add failsafe for locating project root' (#22) from gravel/sessioncommunities.online:php-getenv-failsafe into main

Reviewed-on: #22
pull/29/head
SomeGuy 1 year ago
commit 0aa6430531

@ -1,12 +1,23 @@
<?php
$PROJECT_ROOT = dirname(__FILE__);
while (!file_exists("$PROJECT_ROOT/.phpenv")) {
if ($PROJECT_ROOT == "/" || $PROJECT_ROOT == "")
throw new RuntimeException("Could not find .phpenv file.");
$PROJECT_ROOT = dirname($PROJECT_ROOT);
}
(function(){
global $PROJECT_ROOT;
$root_previous = "";
while (!file_exists("$PROJECT_ROOT/.phpenv")) {
if (
$PROJECT_ROOT == "/" ||
$PROJECT_ROOT == "" ||
$PROJECT_ROOT == $root_previous
)
throw new RuntimeException("Could not find .phpenv file.");
$root_previous = $PROJECT_ROOT;
$PROJECT_ROOT = dirname($PROJECT_ROOT);
}
})();
require_once "$PROJECT_ROOT/.phpenv";
// set_include_path(get_include_path() . PATH_SEPARATOR . $PROJECT_ROOT);