更新 mes_in_sct/start.php #42

Open
james wants to merge 3 commits from james-patch-29 into main

View File

@ -2,7 +2,7 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
// 使用 getopt 函数解析命令行参数
$options = getopt('h::', ['APP_ENV::', 'help::']);
$options = getopt('h', ['APP_ENV:', 'help::']);
// 检查是否请求帮助信息
if (isset($options['h']) || isset($options['help'])) {
echo "Usage: php start.php [options]\n";
@ -11,6 +11,12 @@ if (isset($options['h']) || isset($options['help'])) {
exit;
}
if (isset($options['APP_ENV'])) {
putenv('APP_ENV='.$options['APP_ENV']);
$validEnvs = ['dev', 'test', 'prod'];
if (in_array($options['APP_ENV'], $validEnvs)) {
putenv('APP_ENV='.$options['APP_ENV']);
} else {
echo "Invalid APP_ENV value. Allowed values: " . implode(', ', $validEnvs) . "\n";
exit(1);
}
}
\libs\core\App::run();