-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
Silex middleware for StackPHP | ||
============================= | ||
Symfony middleware for StackPHP | ||
=============================== | ||
|
||
This package contains a [StackPHP middleware](http://stackphp.com/) that unables you to push a Silex | ||
application directly on the middleware stack. The Silex application will try to handle requests but | ||
instead of sending a 404 response if nothing is found, the next middleware on the stack will be called. | ||
This package contains a [StackPHP middleware](http://stackphp.com/) that enables you to push a Symfony | ||
application (actually a `Kernel`) directly on the middleware stack. | ||
The Symfony application will try to handle requests but instead of sending a 404 response if no route is found, | ||
the next middleware on the stack will be called. | ||
|
||
Installation | ||
------------ | ||
|
||
Through [Composer](https://getcomposer.org/) as [mouf/silex-middleware](https://packagist.org/packages/mouf/silex-middleware). | ||
Through [Composer](https://getcomposer.org/) as [mouf/symfony-middleware](https://packagist.org/packages/mouf/symfony-middleware). | ||
|
||
Usage | ||
----- | ||
|
||
Simply use the `SilexMiddleWare` class in your middleware stack: | ||
Simply use the `SymfonyMiddleWare` class in your middleware stack: | ||
|
||
```php | ||
use Mouf\StackPhp\SilexMiddleware; | ||
use Silex\Application; | ||
use Mouf\StackPhp\SymfonyMiddleware; | ||
use My\Symfony\Application; | ||
use Stack\Builder; | ||
|
||
$app = ... | ||
|
||
$silex = new Silex\Application(); | ||
$silex->get('/hello', function(Request $request) { | ||
return 'Hello World!'; | ||
}); | ||
$symfonyApplication = new Application(...); | ||
|
||
$stack = (new Stack\Builder()) | ||
->push(SilexMiddleWare::class, $silex); | ||
->push(SymfonyMiddleware::class, $symfonyApplication); | ||
|
||
$app = $stack->resolve($app); | ||
``` | ||
|
||
Why? | ||
---- | ||
|
||
Why would I want to make a Symfony app a middleware? | ||
Because if every app becomes a middleware, we can easily chain middlewares together, and therefore, chain many | ||
frameworks in the same application... and this is cool :) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters