Added exception if .env not found (#734)

This commit is contained in:
Roman Kelesidis 2023-05-29 15:26:41 +07:00 committed by GitHub
commit f4150ef12c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,9 +63,15 @@ function env(string $key, $default = null)
return \TorrentPier\Env::get($key, $default); return \TorrentPier\Env::get($key, $default);
} }
// Get initial config // Load ENV
try {
$dotenv = Dotenv\Dotenv::createMutable(BB_PATH); $dotenv = Dotenv\Dotenv::createMutable(BB_PATH);
$dotenv->safeLoad(); $dotenv->load();
} catch (\Dotenv\Exception\InvalidPathException $pathException) {
die('Please rename from <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">.env.example</code> to <code style="background:#222;color:#00e01f;padding:2px 6px;border-radius:3px;">.env</code>, and configure it');
}
// Load config
require_once BB_PATH . '/library/config.php'; require_once BB_PATH . '/library/config.php';
// Local config // Local config