Files
dafuweng-buildadmin/dafuweng-webman/phinx-bootstrap.php
2026-03-18 11:22:12 +08:00

50 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Phinx 迁移引导:加载配置使 support\think\Db 可用InstallData 等迁移需检查数据是否存在)
*/
declare(strict_types=1);
$baseDir = __DIR__;
if (!defined('BASE_PATH')) {
define('BASE_PATH', $baseDir);
}
require $baseDir . '/vendor/autoload.php';
if (class_exists('Dotenv\Dotenv') && is_file($baseDir . '/.env')) {
if (method_exists('Dotenv\Dotenv', 'createUnsafeImmutable')) {
Dotenv\Dotenv::createUnsafeImmutable($baseDir)->load();
} else {
Dotenv\Dotenv::createMutable($baseDir)->load();
}
}
if (!function_exists('env')) {
function env(string $key, mixed $default = null): mixed
{
$value = $_ENV[$key] ?? getenv($key);
if ($value !== false && $value !== null) {
return $value;
}
if (strpos($key, '.') !== false) {
$parts = explode('.', $key);
$upper = strtoupper(implode('_', $parts));
$value = $_ENV[$upper] ?? getenv($upper);
if ($value !== false && $value !== null) {
return $value;
}
}
return $default;
}
}
require $baseDir . '/vendor/workerman/webman-framework/src/support/helpers.php';
require $baseDir . '/app/functions.php';
Webman\Config::load($baseDir . '/config', ['route', 'middleware', 'process', 'server', 'static']);
$thinkorm = config('thinkorm', []);
if (!empty($thinkorm)) {
support\think\Db::setConfig($thinkorm);
}