Psr7ServiceProvider
provides Psr-7 integration for the
Silex application micro-framework.
Add silex/psr-7-service-provider
to your project's composer.json
:
{
"require": {
"marvin_b8/psr-7-service-provider": "2.0.x-dev"
}
}
And install:
php composer.phar install
<?php
$app->register(new Silex\Provider\Psr7ServiceProvider());
The Psr-7 provider provides a automatic Psr-7 injection:
<?php
$app->get('/hello', function (\Psr\Http\Message\ServerRequestInterface $request) use($app) {
$request = new \Zend\Diactoros\Response();
$request->getBody()->write(json_encode(array('foo'=>'bar')));
return $request;
));
});
$app->get('/hello', function (\Psr\Http\Message\RequestInterface $request) use($app) {
$request = new \Zend\Diactoros\Response();
$request->getBody()->write(json_encode(array('foo'=>'bar')));
return $request;
));
});
$app->get('/hello', function (\Psr\Http\Message\MessageInterface $request) use($app) {
$request = new \Zend\Diactoros\Response();
$request->getBody()->write(json_encode(array('foo'=>'bar')));
return $request;
));
});