summaryrefslogtreecommitdiff
path: root/src/Http
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-01-18 19:01:34 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-07 16:54:08 +0200
commit3c088292050982505726f5136ff4d0f1a918b879 (patch)
tree8d0e03947935ceb994ef6f8fe01af81bbb268b14 /src/Http
parent2f41b9e4418def9b69cf237312bc592364585025 (diff)
Added Http\Response and Psr7{Request,Response}
Diffstat (limited to 'src/Http')
-rw-r--r--src/Http/Psr7ServiceProvider.php31
-rw-r--r--src/Http/Response.php9
-rw-r--r--src/Http/ResponseServiceProvider.php14
3 files changed, 54 insertions, 0 deletions
diff --git a/src/Http/Psr7ServiceProvider.php b/src/Http/Psr7ServiceProvider.php
new file mode 100644
index 00000000..ff7c13ee
--- /dev/null
+++ b/src/Http/Psr7ServiceProvider.php
@@ -0,0 +1,31 @@
+<?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');
+ $psr7request = $psr7Factory->createRequest($request);
+ $this->app->instance('psr7.request', $psr7request);
+ $this->app->bind(ServerRequestInterface::class, 'psr7.request');
+
+ /** @var Response $response */
+ $response = $this->app->get('response');
+ $psr7response = $psr7Factory->createResponse($response);
+ $this->app->instance('psr7.response', $psr7response);
+ $this->app->bind(ResponseInterface::class, 'psr7.response');
+ }
+}
diff --git a/src/Http/Response.php b/src/Http/Response.php
new file mode 100644
index 00000000..70698fd5
--- /dev/null
+++ b/src/Http/Response.php
@@ -0,0 +1,9 @@
+<?php
+
+namespace Engelsystem\Http;
+
+use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
+
+class Response extends SymfonyResponse
+{
+}
diff --git a/src/Http/ResponseServiceProvider.php b/src/Http/ResponseServiceProvider.php
new file mode 100644
index 00000000..f0d238ef
--- /dev/null
+++ b/src/Http/ResponseServiceProvider.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Engelsystem\Http;
+
+use Engelsystem\Container\ServiceProvider;
+
+class ResponseServiceProvider extends ServiceProvider
+{
+ public function register()
+ {
+ $response = $this->app->make(Response::class);
+ $this->app->instance('response', $response);
+ }
+}