stellarwp/container-contract

StellarWP 容器接口

1.1.1 2023-09-05 20:08 UTC

This package is auto-updated.

Last update: 2024-09-05 22:22:22 UTC


README

StellarWP 库使用的服务容器接口。

注意,这并不是一个容器实现,它仅仅是对依赖注入容器组件的抽象描述。

安装

建议您通过 Composer 将此合约作为项目依赖项安装

composer require stellarwp/container-contract

注意:如果您通常使用像 Strauss 这样的工具,那么您应该 不要 自定义此库的命名空间,以确保与 StellarWP 库的兼容性。

使用方法

只需使用 ContainerInterface 并实现它或将其用作类型提示。

use StellarWP\ContainerContract\ContainerInterface;

class Container implements ContainerInterface {
	public function bind( string $id, $implementation ) {}
	public function get( string $id ) {}
	public function has( string $id ) {}
	public function singleton( string $id, $implementation ) {}
}

其他容器的示例封装