diff --git a/lib/lib.php b/lib/lib.php index bda3947..0071781 100755 --- a/lib/lib.php +++ b/lib/lib.php @@ -1,6 +1,7 @@ register(function ($alias, $class, $args = []) use ($app) { + $app->init(function ($dir) { + $ini = parse_ini_file($dir . '/../.env'); + + defined('APPLICATION_ENV') || define('APPLICATION_ENV', isset($ini['APPLICATION_ENV']) ? $ini['APPLICATION_ENV'] : 'production'); + defined('SITE_NAME') || define('SITE_NAME', isset($ini['SITE_NAME']) ? $ini['SITE_NAME'] : 'project'); + + $root = realpath($dir . '/../'); + + $nameDir = Arrays::last(explode(DS, $root)); + + if (fnmatch('/' . $nameDir . '/*', $_SERVER['REQUEST_URI'])) { + define('FROM_ROOT', $nameDir); + } + + path("base", $root); + path("app", realpath($root . '/app')); + path('public', realpath($dir)); + + systemBoot($dir); + + $errors = []; + + if (!is_writable($dir . '/../app/storage/data')) { + $errors[] = $dir . '/../app/storage/data'; + } + + if (!is_writable($dir . '/../app/storage/cache')) { + $errors[] = $dir . '/../app/storage/cache'; + } + + if (!is_writable($dir . '/../app/storage/tmp')) { + $errors[] = $dir . '/../app/storage/tmp'; + } + + if (!empty($errors)) { + $html = "