madewithlove/definitions
Composer 安装命令:
composer require madewithlove/definitions
包简介
A repository of universal service providers for service-providers compliant containers
README 文档
README
A repository of universal service providers for [service-providers] compliant containers
Install
Via Composer
$ composer require madewithlove/service-providers
This repository does not ship with any third party package, you will need to install them yourself. If per example you need the FlysystemServiceProvider you would install Flysystem alongside this package.
Usage
Service providers
If the container you're using is already compatible with service-provider then register it like you simply would normally.
Otherwise you can use a decorator or bridge, you can find some on Packagist, and this package ships with some as well, per example for league/container:
use League\Flysystem\FilesystemInterface; use League\League\Container; use Madewithlove\ServiceProviders\Bridges\LeagueContainerDecorator; use Madewithlove\ServiceProviders\Filesystem\FlysystemServiceProvider; $container = new LeagueContainerDecorator(new Container()); $container->addServiceProvider(new FlysystemServiceProvider(...))); $filesystem = $container->get(FilesystemInterface::class);
For providers with configuration, you can pass it as constructor argument. See the provider's signature for what options they take:
$provider = new EloquentServiceProvider([ 'local' => [ 'driver' => 'sqlite', 'etc' => 'etc, ], 'production' => [ 'driver' => 'mysql', 'etc' => 'etc, ], ]);
Utilities
This package also ships with some utilities to write your own service providers:
Alias: An alias to an existing value in the container:
public function getServices() { return ['my_alias' => new Alias('to_something_else')]; }
Parameter: A plain value to store in the container:
public function getServices() { return ['views_path' => new Parameter(__DIR__.'/views)]; }
ParametersServiceProvider: A blank service provider to quickly set multiple values in the container:
new ParametersServiceProvider([ 'foo' => 'bar', 'bar' => 'baz', ]); $container->get('foo'); // (string) "bar"
PrefixedProvider: A decorator to prefix a provider's services with a given string:
new PrefixedProvider('config', new ParametersServiceProvider([ 'foo' => 'bar', ])); $container->get('config.foo'); // (string) "bar"
Available service providers
├── Bridges
│ └── LeagueContainerDecorator.php
├── CommandBus
│ └── TacticianServiceProvider.php
├── Console
│ └── SymfonyConsoleServiceProvider.php
├── Database
│ ├── EloquentServiceProvider.php
│ └── FactoryMuffinServiceProvider.php
├── Development
│ ├── DebugbarServiceProvider.php
│ └── MonologServiceProvider.php
├── Events
│ └── LeagueEventsServiceProvider.php
├── Filesystem
│ └── FlysystemServiceProvider.php
├── Http
│ ├── LeagueRouteServiceProvider.php
│ ├── RelayServiceProvider.php
│ └── ZendDiactorosServiceProvider.php
├── Templating
│ └── TwigServiceProvider.php
└── Utilities
├── Alias.php
├── Parameter.php
├── ParametersServiceProvider.php
└── PrefixedProvider.php
See the constructor arguments of each for the options they take. Contributions welcome!
Change log
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING and CONDUCT for details.
Security
If you discover any security related issues, please email heroes@madewithlove.be instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
madewithlove/definitions 适用场景与选型建议
madewithlove/definitions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 94 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 12 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 madewithlove/definitions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 madewithlove/definitions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 94
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-12-08