ph-7/dependency-injection-container
Composer 安装命令:
composer require ph-7/dependency-injection-container
包简介
Simple PHP 7.1+ Dependency Injection Container (DIC) Library.
README 文档
README
Summary ⏳
The "P.H.'s DIC" is a simple and lightweight PHP 7.1+ Dependency Injection Container's library which lets you manage your dependencies easily for your next great project 🎉
Requirements ⚙
Installation 📓
composer require ph-7/dependency-injection-container
Usage 🎮
Register your new DIC as below (FYI, for this example I use the Symfony's HttpFoundation Request).
For the first example, let's create your provider class with an anonymous class that implements the \PierreHenry\Container\Providable interface.
use PierreHenry\Container\Container; use PierreHenry\Container\Providable; use Symfony\Component\HttpFoundation\Request; $container = new Container(); // Register your container $container->register( 'example.symfony.httprequest', new class implements Providable { public function getService(): Request { return Request::createFromGlobals(); } } ); // Retrieve the container $httpRequest = $container->get('example.symfony.httprequest'); // Use it $request = $httpRequest->request; // $_POST body params if ($request->get('get_var')) { echo '$_POST["get var"] exists'; } else { echo '"get_var" has not been requested'; }
Another Example... 🎯
use DateTime; use DateTimeZone; use PierreHenry\Container\Container; use PierreHenry\Container\Providable; $container = new Container(); $container->register( 'stubs.date.datetime', new class implements Providable { public function getService(): DateTime { return new DateTime('now', new DateTimeZone('America/Chicago')); } } ); // Retrieve the container $date = $container->get('stubs.date.datetime'); // Use it echo $date->format('m-d-Y H:i:s');
Inspired By... 🧠
This project is highly inspired by my DIC I built for another side-project.
...Who Am I...? 🤔
Hi there! 😉 I'm Pierre-Henry Soria, "PierreHenry.be™": a cool passionate Belgian software engineer 🇧🇪 😃
You can keep in touch with me at hi {{AT}} ph7 [[D0T]] me!
Passion Drives Me! 🚀
Love programming! 😊 Check out other exciting projects I previously did such as Lifyzer Healthy Food, which gives lots of details about what you eat and allow you do scan your food items 🌯 Another project I'm proud of is the Social Dating WebApp Builder Project I started 8 years ago ☀️
License ⚖
Under GNU GPL v3 or later.
ph-7/dependency-injection-container 适用场景与选型建议
ph-7/dependency-injection-container 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 51 次下载、GitHub Stars 达 12, 最近一次更新时间为 2018 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dependency injection」 「container」 「di」 「dic」 「injection」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ph-7/dependency-injection-container 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ph-7/dependency-injection-container 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ph-7/dependency-injection-container 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A fast and intuitive dependency injection container.
Dependency injection container for the Monolith framework.
The PSR-11 container bridges
Http Microframework for Hack
PHP Dependency Injection Container
统计信息
- 总下载量: 51
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2018-09-02