Skip to content

mbutkereit/psr-7-service-provider

Repository files navigation

Psr7ServiceProvider

Psr7ServiceProvider provides Psr-7 integration for the Silex application micro-framework.

Installation

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

Registering

<?php

$app->register(new Silex\Provider\Psr7ServiceProvider());

Usage

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;
    ));
});

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages