38 lines
931 B
PHP
38 lines
931 B
PHP
<?php
|
|
|
|
use App\Core\Config;
|
|
|
|
// Ensure the configuration class is loaded even if SPL autoloading is not yet available
|
|
if (!class_exists(Config::class, false)) {
|
|
$configPath = __DIR__ . '/../app/Core/Config.php';
|
|
if (file_exists($configPath)) {
|
|
require_once $configPath;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('config')) {
|
|
function config(string $key, $default = null)
|
|
{
|
|
return Config::getInstance()->get($key, $default);
|
|
}
|
|
}
|
|
|
|
if (!function_exists('env')) {
|
|
function env(string $key, $default = null)
|
|
{
|
|
$value = $_ENV[$key] ?? $_SERVER[$key] ?? getenv($key);
|
|
if ($value === false || $value === null) {
|
|
return $default;
|
|
}
|
|
return $value;
|
|
}
|
|
}
|
|
|
|
if (!function_exists('base_path')) {
|
|
function base_path(string $path = ''): string
|
|
{
|
|
$base = realpath(__DIR__ . '/..');
|
|
return $path ? $base . '/' . ltrim($path, '/') : $base;
|
|
}
|
|
}
|