PHPackages                             gonzalo123/injector - 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. gonzalo123/injector

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

gonzalo123/injector
===================

InjectorServiceProvider

1.0(10y ago)8290↓100%1[1 PRs](https://github.com/gonzalo123/injector/pulls)MITPHP

Since Sep 20Pushed 10y ago2 watchersCompare

[ Source](https://github.com/gonzalo123/injector)[ Packagist](https://packagist.org/packages/gonzalo123/injector)[ RSS](/packages/gonzalo123-injector/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

InjectorServiceProvider
=======================

[](#injectorserviceprovider)

[![Build Status](https://camo.githubusercontent.com/f980e749bebbd88775c304589fc8f6a548cae447c6ed0720329ddeaff64df6e8/68747470733a2f2f7472617669732d63692e6f72672f676f6e7a616c6f3132332f696e6a6563746f722e737667)](https://travis-ci.org/gonzalo123/injector)

Alternative way to define service providers in Silex

Let's say we've got this Math class

```
namespace Foo

class Math
{
    public function sum($i, $j)
    {
        return $i+$j;
    }
}
```

And we want to use it within a Silex application

```
include __DIR__ . "/../vendor/autoload.php";

use Silex\Application;
use Foo\Math;

$app            = new Application(['debug' => true]);

$app['math'] = function () {
    return new Math();
};

$app->get("/", function () use ($app) {
    return $app['math']->sum(1, 2);
});

$app->run();
```

We have one Service available in `$app['math']`, but, what's the type of the class? We need to inspect `Math` class to figure out what public functions are available. Sometimes I'm a bit lazy to do that, and because of that I've developed this small service provider to allow us to use a different approach to define our service providers.

```
include __DIR__ . "/../vendor/autoload.php";

use Silex\Application;
use Injector\InjectorServiceProvider;
use Foo\Math;

$app            = new Application(['debug' => true]);

$app->register(new InjectorServiceProvider([
    'Foo\Math' => 'math',
]));

$app['math'] = function () {
    return new Math();
};

$app->get("/", function (Math $math) {
    return $math->sum(1, 2);
});

$app->run();
```

And that's all. Our `InjectorServiceProvider` allows us to define the class provided by the service provider, and its Silex/Pimple key name in the Dependency Injection Container

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% 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

Unknown

Total

1

Last Release

3894d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39072?v=4)[Gonzalo Ayuso](/maintainers/gonzalo123)[@gonzalo123](https://github.com/gonzalo123)

---

Top Contributors

[![gonzalo123](https://avatars.githubusercontent.com/u/39072?v=4)](https://github.com/gonzalo123 "gonzalo123 (8 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (1 commits)")

---

Tags

service providersilex

### Embed Badge

![Health badge](/badges/gonzalo123-injector/health.svg)

```
[![Health](https://phpackages.com/badges/gonzalo123-injector/health.svg)](https://phpackages.com/packages/gonzalo123-injector)
```

###  Alternatives

[igorw/config-service-provider

A config ServiceProvider for Silex with support for php, json and yaml.

215636.5k13](/packages/igorw-config-service-provider)[franmomu/silex-pagerfanta-provider

Silex ServiceProvider for Pagerfanta Library

1312.1k](/packages/franmomu-silex-pagerfanta-provider)[emanueleminotto/faker-service-provider

Faker Service Provider for Silex

162.9k](/packages/emanueleminotto-faker-service-provider)

PHPackages © 2026

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