承接 fresh-advance/regex-dependency 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

fresh-advance/regex-dependency

Composer 安装命令:

composer require fresh-advance/regex-dependency

包简介

Small, configurable service locator/DI container with possibility to describe keys as regular expressions. The component can be used as a Router too.

README 文档

README

Quality Gate Status Coverage Technical Debt Packagist

Small, configurable service locator/DI container with possibility to describe keys as regular expressions. The component can be used as a Router too.

The package is:

  • compliant to PSR-11.
  • follow the PSR-4 and PSR-12
  • works on PHP 7.2+.

Simple case

$configuration = new Collection(
    new Item('key', 'value'),
);

$container = new Container($configuration);
$value = $container->get('key');

var_dump:
  string(5) "value"

Pattern case

$configuration = new Collection(
    new Pattern('examplePattern', '/Example\/.*?$/i', 'SomeValue'),
);

$container = new Container($configuration);
$value = $container->get('Example/Something');

var_dump:
  string(9) "SomeValue"

Value as callback

$configuration = new Collection(
    new Pattern('examplePattern', '/Example\/(?P<special>.*?)$/i', function ($dependency, $match) {
        return $match;
    }),
);

$container = new Container($configuration);
$keyValue = $container->get('Example/Something');

var_dump:
  array(3) {
    [0] => string(17) "Example/Something"
    'special' => string(9) "Something"
    [1] => string(9) "Something"
  }

Two arguments is sent to callbacks:

  • Container $dependency - current instance of container
  • array $match - array with match results: the match response is provided: ['Controller/SomeName', 'SomeName']

Service registry

Objects returned by callbacks are not cached by default, but they can be, if wrapped as a Service.

$configuration = new Collection(
    new Item('someKey', function (Container $dependency) {
        return new Service(new \stdClass());
    })
);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固