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

Reviewed-on: SomeGuy/sessioncommunities.online#22
dev
SomeGuy 1 year ago
commit 03f7ce520d

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

Loading…
Cancel
Save