代码拉取完成,页面将自动刷新
#!/usr/bin/env php
<?php
/**
* FunAdmin ThinkPHP风格命令行工具
* ============================================================================
* 提供类似ThinkPHP的命令行接口,底层使用Webman命令系统
* ============================================================================
* Usage: php think [command] [options]
* Examples:
* php think make:controller User
* php think make:model User
* php think curd --table=users
* php think addon --name=demo
*/
use Webman\Config;
use fun\console\ThinkCommand;
use Webman\Console\Util;
use support\Container;
use Dotenv\Dotenv;
if (!Phar::running()) {
chdir(__DIR__);
}
require_once __DIR__ . '/vendor/autoload.php';
if (!$appConfigFile = config_path('app.php')) {
throw new RuntimeException('Config file not found: app.php');
}
if (class_exists(Dotenv::class) && file_exists(run_path('.env'))) {
if (method_exists(Dotenv::class, 'createUnsafeImmutable')) {
Dotenv::createUnsafeImmutable(run_path())->load();
} else {
Dotenv::createMutable(run_path())->load();
}
}
$appConfig = require $appConfigFile;
if ($timezone = $appConfig['default_timezone'] ?? '') {
date_default_timezone_set($timezone);
}
if ($errorReporting = $appConfig['error_reporting'] ?? '') {
error_reporting($errorReporting);
}
// 不需要处理 webman 服务命令(start, stop, restart等),这些保留给webman脚本
require_once __DIR__ . '/support/bootstrap.php';
// 创建 ThinkPHP 风格的命令行工具
$cli = new ThinkCommand();
$cli->setName('think cli');
$cli->installThinkCommands();
// 加载自定义命令
if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) {
$cli->installCommands($command_path);
}
// 加载自定义命令配置
$customCommands = config('command', []);
foreach ($customCommands as $commandClass) {
if (class_exists($commandClass)) {
try {
$cli->add(new $commandClass());
} catch (\Exception $e) {
// 忽略命令初始化错误,继续加载其他命令
error_log("Failed to load command {$commandClass}: " . $e->getMessage());
}
}
}
// 加载插件命令
foreach (config('plugin', []) as $firm => $projects) {
if (isset($projects['app'])) {
foreach (['', '/app'] as $app) {
if ($command_str = Util::guessPath(base_path() . "/plugin/$firm{$app}", 'command')) {
$command_path = base_path() . "/plugin/$firm{$app}/$command_str";
$cli->installCommands($command_path, "plugin\\$firm" . str_replace('/', '\\', $app) . "\\$command_str");
}
}
}
foreach ($projects as $name => $project) {
if (!is_array($project)) {
continue;
}
$project['command'] ??= [];
array_walk($project['command'], [$cli, 'createCommandInstance']);
}
}
$cli->run();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。