26 Star 122 Fork 16

hunzhiwange/QueryPHP

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
leevel 1.57 KB
一键复制 编辑 原始数据 按行查看 历史
小牛New 提交于 2024-05-17 15:10 +08:00 . 优化目录
#!/usr/bin/env php
<?php
declare(strict_types=1);
use App\Infra\Exceptions\Runtime;
use App\Infra\Kernel\Kernel;
use App\Infra\Kernel\KernelConsole;
use Leevel\Di\Container;
use Leevel\Di\IContainer;
use Leevel\Kernel\App;
use Leevel\Kernel\IApp;
use Leevel\Kernel\Exceptions\IRuntime;
use Leevel\Kernel\IKernel;
use Leevel\Kernel\IKernelConsole;
use Symfony\Component\Console\Input\ArgvInput;
// 加载 Composer
require __DIR__.'/vendor/autoload.php';
// 创建应用
// 注册应用基础服务
$container = Container::singletons();
$container->singleton(IContainer::class, $container);
// 应用路径
$path = str_starts_with(__DIR__, 'phar://')
? Phar::running()
: realpath(__DIR__);
$container->singleton('app', $app = new App($container, $path));
// PHAR 缓存路径不能是 phar 内部路径,因为 phar 内部路径是只读的
if (str_starts_with(__DIR__, 'phar://')) {
$app->setStoragePath(substr(dirname(Phar::running()), 7).\DIRECTORY_SEPARATOR.'storage');
}
$container->alias('app', [IApp::class, App::class]);
$container->singleton(IKernel::class, Kernel::class);
$container->singleton(IKernelConsole::class, KernelConsole::class);
$container->singleton(IRuntime::class, Runtime::class);
// 载入环境
$input = new ArgvInput();
if ($input->hasParameterOption('--env')) {
$env = $input->getParameterOption('--env');
} else {
$env = 'env';
}
putenv('RUNTIME_ENVIRONMENT='.$env);
// 执行应用
// 根据内核调度请求返回响应
$kernel = $container->make(IKernelConsole::class);
$status = $kernel->handle();
$kernel->terminate($status);
exit($status);
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/dyhb/queryphp.git
git@gitee.com:dyhb/queryphp.git
dyhb
queryphp
QueryPHP
master

搜索帮助