Initial commit: Slim Framework 4 API Retribusi dengan modular architecture

This commit is contained in:
mwpn
2025-12-17 10:43:03 +07:00
commit 39f23388a7
45 changed files with 5439 additions and 0 deletions

41
src/Config/AppConfig.php Normal file
View File

@@ -0,0 +1,41 @@
<?php
declare(strict_types=1);
namespace App\Config;
use Dotenv\Dotenv;
class AppConfig
{
/**
* Load environment variables from .env file
* Safe if .env file doesn't exist
*
* @param string $rootPath
* @return void
*/
public static function loadEnv(string $rootPath): void
{
$envPath = $rootPath . DIRECTORY_SEPARATOR . '.env';
if (file_exists($envPath)) {
$dotenv = Dotenv::createImmutable($rootPath);
$dotenv->load();
}
}
/**
* Get environment variable with default value
*
* @param string $key
* @param string|null $default
* @return string|null
*/
public static function get(string $key, ?string $default = null): ?string
{
$value = $_ENV[$key] ?? $_SERVER[$key] ?? getenv($key);
return $value !== false ? (string) $value : $default;
}
}

28
src/Config/app.php Normal file
View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace App\Config;
use Dotenv\Dotenv;
class AppConfig
{
/**
* Load environment variables from .env file
* Safe if .env file doesn't exist
*
* @param string $rootPath
* @return void
*/
public static function loadEnv(string $rootPath): void
{
$envPath = $rootPath . DIRECTORY_SEPARATOR . '.env';
if (file_exists($envPath)) {
$dotenv = Dotenv::createImmutable($rootPath);
$dotenv->load();
}
}
}