PHPackages                             derrabus/silex-psr11-provider - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. derrabus/silex-psr11-provider

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

derrabus/silex-psr11-provider
=============================

Privides a PSR-11 compatible container as a service.

v1.1.2(5y ago)48.8kMITPHPPHP ^5.5.9 || ^7 || ^8

Since Feb 6Pushed 5y ago2 watchersCompare

[ Source](https://github.com/derrabus/silex-psr11-provider)[ Packagist](https://packagist.org/packages/derrabus/silex-psr11-provider)[ RSS](/packages/derrabus-silex-psr11-provider/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

Psr11ServiceProvider
====================

[](#psr11serviceprovider)

This service provider registers a PSR-11 compatible container as a service inside a [Silex](https://github.com/silexphp/Silex) application.

PSR-11 enables developers to write code that is aware of the service container without coupling it to a specific container implementation, thus allowing to switch to another service container more easily.

[![Build Status](https://camo.githubusercontent.com/8f851c194a42df91bab85e59de0fd93ae698942114e5b720ff12f9d958458b8e/68747470733a2f2f7472617669732d63692e6f72672f64657272616275732f73696c65782d70737231312d70726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/derrabus/silex-psr11-provider)

Installation
------------

[](#installation)

Use [Composer](https://getcomposer.org/) to install the package.

```
composer require derrabus/silex-psr11-provider

```

Usage
-----

[](#usage)

Once you have registered the service provider, you can either access the container as service `service_container` or as a controller argument by using `Psr\Container\ContainerInterface` as type hint.

Examples
--------

[](#examples)

```
use Psr\Container\ContainerInterface;
use Rabus\Psr11ServiceProvider\Psr11ServiceProvider;
use Silex\Application;
use Silex\Provider\ServiceControllerServiceProvider;
use Symfony\Component\HttpFoundation\RedirectResponse;

class SomeController
{
    private $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function someAction()
    {
        return new RedirectResponse(
            $this->container->get('url_generator')->generate('home')
        );
    }
}

$app = new Application();
$app->register(new ServiceControllerServiceProvider());
$app->register(new Psr11ServiceProvider());

$app['some_controller'] = function ($app) {
    // Inject a PSR-11 container instead of the $app
    return new SomeController($app['service_container']);
};

$app->get('/', function() {
    return 'Home.';
})->bind('home');

$app->get('/test1', 'some_controller:someAction');

// Type-hint the PSR-11 container instead of the $app
$app->get('/test2', function (ContainerInterface $container) {
    new RedirectResponse($container->get('url_generator')->generate('home'));
});
```

Blog
----

[](#blog)

This service provider can be used as a stepping stone on the migration path from Silex to Symfony. It has been created to illustrate how to [decouple Silex applications from the service container implementation](https://medium.com/@derrabus/decoupling-silex-applications-from-the-service-container-implementation-635263f05e52).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~297 days

Total

4

Last Release

2125d ago

PHP version history (2 changes)v1.0PHP ^5.5.9 || ^7

v1.1.2PHP ^5.5.9 || ^7 || ^8

### Community

Maintainers

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

---

Top Contributors

[![derrabus](https://avatars.githubusercontent.com/u/1506493?v=4)](https://github.com/derrabus "derrabus (17 commits)")

---

Tags

psr-11silex-provider

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/derrabus-silex-psr11-provider/health.svg)

```
[![Health](https://phpackages.com/badges/derrabus-silex-psr11-provider/health.svg)](https://phpackages.com/packages/derrabus-silex-psr11-provider)
```

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M343](/packages/league-container)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)[api-platform/state

API Platform state interfaces

223.4M57](/packages/api-platform-state)[dragon-code/contracts

A set of contracts for any project

108.8M37](/packages/dragon-code-contracts)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)

PHPackages © 2026

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