定制 madewithlove/definitions 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

madewithlove/definitions

Composer 安装命令:

composer require madewithlove/definitions

包简介

A repository of universal service providers for service-providers compliant containers

README 文档

README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

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.

统计信息

  • 总下载量: 94
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固