summaryrefslogtreecommitdiff
path: root/src/Http/Psr7ServiceProvider.php
blob: 72fdef8e3618af31a91d6281ad5df2df75e0b5ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

namespace Engelsystem\Http;

use Engelsystem\Container\ServiceProvider;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;


class Psr7ServiceProvider extends ServiceProvider
{
    public function register()
    {
        /** @var DiactorosFactory $psr7Factory */
        $psr7Factory = $this->app->make(DiactorosFactory::class);
        $this->app->instance('psr7.factory', $psr7Factory);

        /** @var Request $request */
        $request = $this->app->get('request');
        $this->app->instance('psr7.request', $request);
        $this->app->bind(ServerRequestInterface::class, 'psr7.request');

        /** @var Response $response */
        $response = $this->app->get('response');
        $this->app->instance('psr7.response', $response);
        $this->app->bind(ResponseInterface::class, 'psr7.response');
    }
}