PHPackages                             mouf/mvc.silex-mouf - 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/mvc.silex-mouf

ActiveLibrary[Framework](/categories/framework)

mouf/mvc.silex-mouf
===================

This project is a very simple extension to the Silex microframework. It adds Mouf dependency injection capability to Silex.

1.0.x-dev(12y ago)010MITPHP

Since Sep 6Pushed 12y ago10 watchersCompare

[ Source](https://github.com/thecodingmachine/mvc.silex-mouf)[ Packagist](https://packagist.org/packages/mouf/mvc.silex-mouf)[ Docs](http://mouf-php.com)[ RSS](/packages/mouf-mvcsilex-mouf/feed)WikiDiscussions 1.0 Synced yesterday

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

Silex with Mouf Dependency Injection compatibility
==================================================

[](#silex-with-mouf-dependency-injection-compatibility)

This project is a very simple extension to the [Silex microframework](http://silex.sensiolabs.org/). It adds [Mouf dependency injection](http://mouf-php.com) capability to Silex.

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 use [Mouf](http://mouf-php.com), a graphical dependency injection framework directly in your Silex project. Instead of injecting your dependencies by filling the `$app` variable, you can use Mouf user interface to declare your instances.

How?
----

[](#how)

The extended `Application` class has only one additonnal method: `registerMoufManager()`. This is used to register the Mouf DIC instance into Silex.

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

Here is a sample about injecting a controller in Pimple.

- Install this package using Composer.
- This package depends on Mouf. Once Mouf is downloaded, you need to [install Mouf](http://mouf-php.com/packages/mouf/mouf/doc/installing_mouf.md).
- Then, declare a simple test controller: ```
