buzzingpixel/mission-control-backend-core

dev-main 2023-11-09 15:33 UTC

This package is auto-updated.

Last update: 2024-09-09 17:39:21 UTC


README

此包包含Mission Control后端的基本设置功能。

使用composer将其要求添加到您的项目中。

composer require buzzingpixel/mission-control-backend-core

HTTP

在您的Web入口点前端控制器(通常为公共目录中的index.php),启动并运行HTTP应用程序,如下所示

<?php

declare(strict_types=1);

use MissionControlBackend\Boot;
use MissionControlBackendApp\Config\BootHttpMiddlewareConfigFactory;
use MissionControlBackendApp\Config\CoreConfigFactory;
use MissionControlBackendApp\Config\Dependencies\DependencyBindings;
use MissionControlBackendApp\Config\Events\EventRegistration;

require dirname(__DIR__) . '/vendor/autoload.php';

(new Boot())
    // The first argument of `start` must be an instance of
    // `\MissionControlBackend\CoreConfig` and is required
    ->start((new CoreConfigFactory())->create())
    // The first argument of `buildContainer` accepts a callable that receives
    // an instance of `\MissionControlBackend\ContainerBindings` which you can
    // use to register container bindings. As you require other mission-control
    // packages, you will need to add that package's dependency bindings here 
    ->buildContainer([DependencyBindings::class, 'register'])
    // The first argument of `registerEvents` accepts a callable that receives
    // an instance of `\Crell\Tukio\OrderedProviderInterface` which you can use
    // to register events. As you require other mission-control packages, you
    // will need to add that package's event bindings here
    ->registerEvents([EventRegistration::class, 'register'])
    ->buildHttpApplication()
    ->applyRoutes()
    // The first argument of `applyMiddleware` must be an instance of
    // `\MissionControlBackend\Http\BootHttpMiddlewareConfig` and is required
    ->applyMiddleware((new BootHttpMiddlewareConfigFactory())->create())
    ->runApplication();

从示例中可以看出,启动过程的一定部分接受或需要参数,如何实现取决于您。请参阅Dev环境中的示例:[https://github.com/buzzingpixel-mission-control/dev](https://github.com/buzzingpixel-mission-control/dev)

CLI

在您的CLI入口点,启动并运行CLI应用程序,如下所示

#!/usr/bin/env php
<?php

use MissionControlBackend\Boot;
use MissionControlBackendApp\Config\CoreConfigFactory;
use MissionControlBackendApp\Config\Dependencies\DependencyBindings;
use MissionControlBackendApp\Config\Events\EventRegistration;

require __DIR__ . '/vendor/autoload.php';

(new Boot())
    // The first argument of `start` must be an instance of
    // `\MissionControlBackend\CoreConfig` and is required. This is exactly the
    // same as above in the web entry point
    ->start((new CoreConfigFactory)->create())
    // The first argument of `buildContainer` accepts a callable that receives
    // an instance of `\MissionControlBackend\ContainerBindings` which you can
    // use to register container bindings. As you require other mission-control
    // packages, you will need to add that packages dependency bindings here.
    // This is exactly the same as above in the web entry point
    ->buildContainer([DependencyBindings::class, 'register'])
    // The first argument of `registerEvents` accepts a callable that receives
    // an instance of `\Crell\Tukio\OrderedProviderInterface` which you can use
    // to register events. As you require other mission-control packages, you
    // will need to add that package's event bindings here. This is exactly the
    // same as above in the web entry point
    ->registerEvents([EventRegistration::class, 'register'])
    ->buildCliApplication()
    ->applyCommands()
    ->runApplication();

依赖关系和事件

需要许多依赖关系和事件。当您第一次启动应用程序时,异常信息应该非常清晰,说明您需要设置什么。有关更多信息,请参阅[https://github.com/buzzingpixel-mission-control/dev](https://github.com/buzzingpixel-mission-control/dev)。

此项目主要是为我而设,因此,在此阶段很难振作起来编写完整的文档。