PHPackages                             lefuturiste/slim-bridge - 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. lefuturiste/slim-bridge

ActiveLibrary

lefuturiste/slim-bridge
=======================

PHP-DI integration in Slim

1.0.6(5y ago)04373MITPHPPHP &gt;=5.5

Since Dec 28Pushed 5y agoCompare

[ Source](https://github.com/lefuturiste/slim-bridge)[ Packagist](https://packagist.org/packages/lefuturiste/slim-bridge)[ RSS](/packages/lefuturiste-slim-bridge/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (4)Versions (16)Used By (3)

PHP-DI integration with Slim
============================

[](#php-di-integration-with-slim)

This package configures Slim 3 to work with the [PHP-DI container](http://php-di.org/).

[![Build Status](https://camo.githubusercontent.com/59865324e9f001b75368b66e74c36fa25edee9d42eb865784999e9b750b9531f/68747470733a2f2f7472617669732d63692e6f72672f5048502d44492f536c696d2d4272696467652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/PHP-DI/Slim-Bridge)[![](https://camo.githubusercontent.com/766fa1cc0aa13e27d5dddbdd33d996876968595772c7ea5e6528543e34f5231e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d64692f736c696d2d6272696467652e737667)](https://packagist.org/packages/php-di/slim-bridge)

The full documentation is here: ****

Why?
----

[](#why)

### PHP-DI as a container

[](#php-di-as-a-container)

The most obvious difference with the default Slim installation is that you will be using PHP-DI as the container, which has the following benefits:

- [autowiring](http://php-di.org/doc/autowiring.html)
- powerful [configuration format](http://php-di.org/doc/php-definitions.html)
- support for [modular systems](http://php-di.org/doc/definition-overriding.html)
- ...

If you want to learn more about all that PHP-DI can offer [have a look at its introduction](http://php-di.org/).

### Controllers as services

[](#controllers-as-services)

While your controllers can be simple closures, you can also **write them as classes and have PHP-DI instantiate them only when they are called**:

```
class UserController
{
    private $userRepository;

    public function __construct(UserRepository $userRepository)
    {
        $this->userRepository = $userRepository;
    }

    public function delete($request, $response)
    {
        $this->userRepository->remove($request->getAttribute('id'));

        $response->getBody()->write('User deleted');
        return $response;
    }
}

$app->delete('/user/{id}', ['UserController', 'delete']);
```

Dependencies can then be injected in your controller using [autowiring, PHP-DI config files or even annotations](http://php-di.org/doc/definition.html).

### Controller parameters

[](#controller-parameters)

By default, Slim controllers have a strict signature: `$request, $response, $args`. The PHP-DI bridge offers a more flexible and developer friendly alternative.

Controller parameters can be any of these things:

- request or response injection (parameters must be named `$request` or `$response`)
- request attribute injection
- service injection (by type-hint)

You can mix all these types of parameters together too. They will be matched by priority in the order of the list above.

#### Request or response injection

[](#request-or-response-injection)

You can inject the request or response in the controller parameters by name:

```
$app->get('/', function (ResponseInterface $response, ServerRequestInterface $request) {
    // ...
});
```

As you can see, the order of the parameters doesn't matter. That allows to skip injecting the `$request` if it's not needed for example.

#### Request attribute injection

[](#request-attribute-injection)

```
$app->get('/hello/{name}', function ($name, ResponseInterface $response) {
    $response->getBody()->write('Hello ' . $name);
    return $response;
});
```

As you can see above, the route's URL contains a `name` placeholder. By simply adding a parameter **with the same name** to the controller, PHP-DI will directly inject it.

#### Service injection

[](#service-injection)

To inject services into your controllers, you can write them as classes. But if you want to write a micro-application using closures, you don't have to give up dependency injection either.

You can inject services by type-hinting them:

```
$app->get('/', function (ResponseInterface $response, Twig $twig) {
    return $twig->render($response, 'home.twig');
});
```

> Note: you can only inject services that you can type-hint and that PHP-DI can provide. Type-hint injection is simple, it simply injects the result of `$container->get(/* the type-hinted class */)`.

Documentation
-------------

[](#documentation)

The documentation can be read here: ****

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 79.6% 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 ~160 days

Recently: every ~321 days

Total

13

Last Release

1862d ago

Major Versions

0.2.1 → 1.0.02016-03-08

PHP version history (3 changes)0.1.0PHP ~5.6|~7.0

1.0.2PHP ~5.5|~7.0

1.0.6PHP &gt;=5.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/237a43763134833e785eaee2c646dc218b63a87a8b0943b585a7c9ce436fd306?d=identicon)[lefuturiste](/maintainers/lefuturiste)

---

Top Contributors

[![mnapoli](https://avatars.githubusercontent.com/u/720328?v=4)](https://github.com/mnapoli "mnapoli (39 commits)")[![lefuturiste](https://avatars.githubusercontent.com/u/20988163?v=4)](https://github.com/lefuturiste "lefuturiste (7 commits)")[![danmichaelo](https://avatars.githubusercontent.com/u/434495?v=4)](https://github.com/danmichaelo "danmichaelo (1 commits)")[![tflight](https://avatars.githubusercontent.com/u/4959691?v=4)](https://github.com/tflight "tflight (1 commits)")[![vonalbert](https://avatars.githubusercontent.com/u/6561324?v=4)](https://github.com/vonalbert "vonalbert (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lefuturiste-slim-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/lefuturiste-slim-bridge/health.svg)](https://phpackages.com/packages/lefuturiste-slim-bridge)
```

###  Alternatives

[respect/validation

The most awesome validation engine ever created for PHP

5.9k37.4M383](/packages/respect-validation)[zbateson/mail-mime-parser

MIME email message parser

53949.2M79](/packages/zbateson-mail-mime-parser)[php-di/slim-bridge

PHP-DI integration in Slim

1786.7M98](/packages/php-di-slim-bridge)[phlak/directory-lister

PHP directory lister

2.5k1.4k](/packages/phlak-directory-lister)[infinum/eightshift-libs

WordPress libs developed by Eightshift team to use in modern WordPress.

63118.9k3](/packages/infinum-eightshift-libs)[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)

PHPackages © 2026

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