icanboogie/service
Composer 安装命令:
composer require icanboogie/service
包简介
A dependency-injection container agnostic service provider
README 文档
README
ICanBoogie/Service provides means to reference, resolve, and invoke services using your favorite dependency injection container, in the most transparent way possible.
Please, consider the following example:
<?php use ICanBoogie\Service\ServiceProvider; use function ICanBoogie\Service\ref; ServiceProvider::define(function ($id) { if ($id === 'hello') { return function ($name = "world") { return "Hello $name!"; }; } throw new \LogicException("Unknown service: $id"); }); # getting a service through the provider $service = ServiceProvider::provide('hello'); echo $service("Madonna"); // Hello Madonna! # using a reference $reference = ref('hello'); echo $reference; // hello echo $reference("Madonna"); // Hello Madonna!
References are callables
Service references created with ref are especially useful when you need to provide a callable
but you don't want that callable to be instantiated right away:
<?php use function ICanBoogie\Service\ref; class Compute { public function __construct(callable $computer) { // … } // … } $compute = new Compute(ref('expansive_instance'));
References can be exported
ServiceReference instances can safely be exported with var_export():
<?php use ICanBoogie\Service\ServiceReference; $id = 'my_service'; $reference = new ServiceReference($id); $dump = var_export($reference, true); $r = eval("return $dump;"); echo get_class($r); // ICanBoogie\Service\ServiceReference echo (string) $r; // my_service
Requirements
The package requires PHP 5.6 or later.
Installation
The recommended way to install this package is through Composer:
$ composer require ICanBoogie/Service
Cloning the repository
The package is available on GitHub, its repository can be cloned with the following command line:
$ git clone https://github.com/ICanBoogie/Service.git
Documentation
The package is documented as part of the [ICanBoogie][] framework documentation. You can
generate the documentation for the package and its dependencies with the make doc command. The
documentation is generated in the build/docs directory. ApiGen is required.
The directory can later be cleaned with the make clean command.
Testing
The test suite is ran with the make test command. PHPUnit and
Composer need to be globally available to run the suite. The command
installs dependencies as required. The make test-coverage command runs test suite and also creates
an HTML coverage report in build/coverage. The directory can later be cleaned with the make clean command.
The package is continuously tested by Travis CI.
License
ICanBoogie/Service is licensed under the New BSD License - See the LICENSE file for details.
icanboogie/service 适用场景与选型建议
icanboogie/service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 954 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 02 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「dependency」 「injection」 「provider」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 icanboogie/service 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 icanboogie/service 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 icanboogie/service 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Time provider, providing consistent current date, time, datetime and timezone across the request.
An Zend Expressive module for loading ZF2 or ZF3 modules.
A fast and intuitive dependency injection container.
Planning Center OAuth2 Provider for Laravel Socialite
Data provider for yii2
Dependency injection container for the Monolith framework.
统计信息
- 总下载量: 954
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 27
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2017-02-02