alanvdb/pimple-container-factory
最新稳定版本:v0.1
Composer 安装命令:
composer require alanvdb/pimple-container-factory
包简介
Factories for Pimple containers
README 文档
README
A lightweight factory for creating Pimple containers, including support for PSR-11 compliant containers.
Features
- Simple container factory based on Pimple
- PSR-11 container wrapper using
Pimple\Psr11\Container - Designed with interface abstraction for testability and extensibility
Installation
You can install this package via Composer:
composer require alanvdb/pimple-container-factory
Usage
Basic Pimple Container
To create a raw Pimple container:
use AlanVdb\Container\Factory\PimpleContainerFactory; $factory = new PimpleContainerFactory(); $container = $factory->createContainer([ 'service' => function () { return new \Some\Service(); }, ]); $service = $container['service'];
PSR-11 Compatible Container
To create a container compatible with Psr\Container\ContainerInterface:
use AlanVdb\Container\Factory\PimplePsr11ContainerFactory; $factory = new PimplePsr11ContainerFactory(); $container = $factory->createContainer([ 'service' => function () { return new \Some\Service(); }, ]); $service = $container->get('service');
Interfaces
This package uses interfaces for container factories, located under:
- AlanVdb\Container\Definition\PimpleContainerFactoryInterface
- AlanVdb\Container\Definition\ContainerFactoryInterface
You can rely on these interfaces for dependency injection or testing purposes.
Requirements
PHP 8.2 or higher
License
This package is open-source and licensed under the MIT License.
Made with ❤️ by AlanVdb
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-22