PHPackages                             fresh-advance/regex-dependency - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fresh-advance/regex-dependency

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

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.

v0.3.0(6y ago)132MITPHPPHP &gt;=7.2

Since Jun 3Pushed 5y agoCompare

[ Source](https://github.com/Fresh-Advance/regex-dependency)[ Packagist](https://packagist.org/packages/fresh-advance/regex-dependency)[ RSS](/packages/fresh-advance-regex-dependency/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (5)Used By (0)

RegEx Dependency Container
==========================

[](#regex-dependency-container)

[![Quality Gate Status](https://camo.githubusercontent.com/06a7bb394caf0f0574978ecbd73ed6e2fdeffd8633913fcc0b709992d8e2c6a6/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d46726573682d416476616e63655f72656765782d646570656e64656e6379266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=Fresh-Advance_regex-dependency)[![Coverage](https://camo.githubusercontent.com/fd4879ae07c122d1ea8f0709d984c178fd95882f2dfeb93a0717828db1d524ad/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d46726573682d416476616e63655f72656765782d646570656e64656e6379266d65747269633d636f766572616765)](https://sonarcloud.io/dashboard?id=Fresh-Advance_regex-dependency)[![Technical Debt](https://camo.githubusercontent.com/aa515fdb63f83f22ddb57ec14ea1c3faa9fce28635e78e0463bb34e3e68688e8/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d46726573682d416476616e63655f72656765782d646570656e64656e6379266d65747269633d7371616c655f696e646578)](https://sonarcloud.io/dashboard?id=Fresh-Advance_regex-dependency)[![Packagist](https://camo.githubusercontent.com/957cba2661e4c48a27f1d8b9d054a9c02c7db177d983cd7736a2446de586ac72/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66726573682d616476616e63652f72656765782d646570656e64656e63792e737667)](https://packagist.org/packages/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.

The package is:

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

Simple case
-----------

[](#simple-case)

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

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

var_dump:
  string(5) "value"

```

Pattern case
------------

[](#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
-----------------

[](#value-as-callback)

```
$configuration = new Collection(
    new Pattern('examplePattern', '/Example\/(?P.*?)$/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
----------------

[](#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());
    })
);

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~296 days

Total

4

Last Release

2372d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf25d2c148579fed45c9fcaa19c3de35a750fa774812fbb5c30149f42f470215?d=identicon)[sieg](/maintainers/sieg)

---

Top Contributors

[![Sieg](https://avatars.githubusercontent.com/u/98882?v=4)](https://github.com/Sieg "Sieg (70 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/fresh-advance-regex-dependency/health.svg)

```
[![Health](https://phpackages.com/badges/fresh-advance-regex-dependency/health.svg)](https://phpackages.com/packages/fresh-advance-regex-dependency)
```

###  Alternatives

[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k431.1M7.4k](/packages/symfony-dependency-injection)[illuminate/contracts

The Illuminate Contracts package.

704122.9M10.0k](/packages/illuminate-contracts)[illuminate/container

The Illuminate Container package.

31278.1M2.0k](/packages/illuminate-container)[symfony/type-info

Extracts PHP types information.

19751.9M114](/packages/symfony-type-info)[ecotone/ecotone

Supporting you in building DDD, CQRS, Event Sourcing applications with ease.

558549.8k17](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k17](/packages/civicrm-civicrm-core)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
