PHPackages                             mouf/interop.silex.di - 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. [Framework](/categories/framework)
4. /
5. mouf/interop.silex.di

ActiveLibrary[Framework](/categories/framework)

mouf/interop.silex.di
=====================

This project is a very simple extension to the Silex microframework. It adds to Silex the capability to use any DI container (not only Pimple).

2.0.x-dev(11y ago)772.6kMITPHP

Since Dec 18Pushed 11y ago12 watchersCompare

[ Source](https://github.com/thecodingmachine/interop.silex.di)[ Packagist](https://packagist.org/packages/mouf/interop.silex.di)[ Docs](http://mouf-php.com)[ RSS](/packages/mouf-interopsilexdi/feed)WikiDiscussions 2.0 Synced yesterday

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

Run Silex with any Dependency Injection container
=================================================

[](#run-silex-with-any-dependency-injection-container)

This project is a very simple extension to the [Silex microframework](http://silex.sensiolabs.org/). It makes Silex able to use any other dependency container compatible with [container-interop](https://github.com/container-interop/container-interop/) (and not only Pimple).

To use this, you simply need to use the `Mouf\Interop\Silex\Application` class that extends the `Silex\Application` class.

Why?
----

[](#why)

Silex is a microframework. It is designed on top of Pimple, a very simple dependency injection container (DIC) written in about 80 lines of code. Pimple is a nice DIC, but it can become quite verbose as your project grows. And natively, Silex has no way to use another DIC (the `Application` class of Silex extends the `Pimple` class).

This project lets you add any other dependency injection framework directly in your Silex project. Instead of injecting your dependencies by filling the `$app` variable, you can register entries in your own container. Instances declared in your container will be accessible using the Pimple `$app['my.instance']` syntax.

How?
----

[](#how)

The extended `Application` class has a modified constructor:

- \_\_construct(ContainerInterface $container = null, array $values = array())

The container passed in parameter is a [delegate lookup container](https://github.com/container-interop/container-interop/blob/master/docs/Delegate-lookup.md).

When this is done, you can access any instance declared of your container using the `$app` object, just like you would in any Silex project.

Your DI container must respect the [`ContainerInterface` described in this the container-interop project.](https://github.com/container-interop/container-interop)

What DI containers can I plug in Silex?
---------------------------------------

[](#what-di-containers-can-i-plug-in-silex)

Out of the box, you can plug any of the DI containers supported by container-interop. There are an awful lot of them!

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

[](#installation)

This class is distributed as a [Composer package](https://packagist.org/packages/mouf/interop.silex.di):

```
{
	require: {
		"mouf/interop.silex.di" : "~2.0"
	}
}

```

See a working sample
--------------------

[](#see-a-working-sample)

Check out this use case: [creating a Silex controller with the Mouf framework](doc/declaring-a-controller-with-mouf.md)

You are a Symfony 2 user?
-------------------------

[](#you-are-a-symfony-2-user)

There is a very similar package for Symfony 2 application. It lets you add additional containers to the main Symfony 2 container: [check it out: interop.symfony.di](https://github.com/thecodingmachine/interop.symfony.di)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

4117d ago

Major Versions

1.0.x-dev → 2.0.x-dev2015-02-02

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1104771?v=4)[mouf](/maintainers/mouf)[@Mouf](https://github.com/Mouf)

---

Top Contributors

[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (10 commits)")

---

Tags

frameworkdependency-injectiondiiocmicroframeworksilexinversion of control

### Embed Badge

![Health badge](/badges/mouf-interopsilexdi/health.svg)

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

###  Alternatives

[mouf/mouf

The Mouf PHP framework: an open-source PHP framework providing an easy way to download, install, use and reuse components, with a graphical user interface.

55146.0k17](/packages/mouf-mouf)[joomla/di

Joomla DI Package

15391.2k11](/packages/joomla-di)[vesparny/silex-simple-rest

A simple silex skeleton for rest api

3346.8k](/packages/vesparny-silex-simple-rest)[mouf/pimple-interop

This project is a very simple extension to the Pimple microframework. It adds to Pimple compatibility with the container-interop APIs.

102.4M2](/packages/mouf-pimple-interop)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)

PHPackages © 2026

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