Files
shop-platform/src/think

34 lines
858 B
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.
#!/usr/bin/env php
<?php
namespace think;
// 命令行入口文件
// 加载基础文件
require __DIR__ . '/vendor/autoload.php';
// 创建应用程序
$app = new App();
// 1. 先加载基础.env文件
if (is_file(__DIR__ . '/.env')) {
$app->env->load(__DIR__ . '/.env');
}
// 2. 根据APP_ENV加载环境特定的.env文件
$appEnv = getenv('APP_ENV') ?: '';
if ($appEnv) {
$envFile = __DIR__ . '/.env.' . $appEnv;
if (is_file($envFile)) {
$app->env->load($envFile);
}
} else {
echo "⚠️ 警告未设置APP_ENV环境变量默认使用local环境。\n";
// 3. 为了兼容性,如果存在.env.local也加载优先级最高
if (is_file(__DIR__ . '/.env.local')) {
$app->env->load(__DIR__ . '/.env.local');
}
}
// 应用初始化
$app->console->run();