Files
webman-buildadmin/phinx-bootstrap.php
2026-03-21 17:39:43 +08:00

51 lines
1.5 KiB
PHP
Raw 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']);
// 与 phinx.php 一致直接加载 thinkorm避免 Webman config() 与 Phinx 表前缀不一致
$thinkorm = require $baseDir . '/config/thinkorm.php';
if (!empty($thinkorm)) {
support\think\Db::setConfig($thinkorm);
}