juststeveking/micro-core

一个用于微模板框架的核心组件集合。

dev-main 2021-07-01 18:57 UTC

This package is auto-updated.

Last update: 2024-08-29 05:44:07 UTC


README

这是一个用于Micro 模板的核心组件集合,适用于精简框架。

此包的目的是提供一个一致的方式来启动 SlimPHP 项目,允许您根据核心提供的接口实现具体实现。

接口

主要接口是我们的 KernelContract,这是应用程序的入口点。这里是构建 Slim 和添加我们容器的地方。

这里建议您这样做

use JustSteveKing\Micro\Contracts\KernelContract;
use JustSteveKing\Micro\Kernel;
use Psr\Container\ContainerInterface;

return [
    KernelContract::class => function (ContainerInterface $container) {
        return Kernel::boot(
            basePath: __DIR__ . '/../', // this is the path to the root of your project.
            container: $container, // this will be the build container.
        );
    },
];

在上面的示例中,我们向容器中添加了一个 Kernel 的条目,使用默认提供的内核和传递基本选项。您可以轻松地覆盖此 Kernel 类 - 只需确保它实现了相同的接口。