From f936e64e2f45299bff6a885ddc91b75fb8bbf58d Mon Sep 17 00:00:00 2001 From: Igor Tarasov Date: Mon, 21 Jan 2019 21:19:13 +0300 Subject: [PATCH] Add support for Symfony Response creation This would make response method play nice with Symfony, Silex and any other project that uses Symfony's http stack. --- src/Intervention/Image/Response.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Intervention/Image/Response.php b/src/Intervention/Image/Response.php index 8e5c7cac..78b953e5 100644 --- a/src/Intervention/Image/Response.php +++ b/src/Intervention/Image/Response.php @@ -57,6 +57,12 @@ class Response $response->header('Content-Type', $mime); $response->header('Content-Length', $length); + } elseif (class_exists(\Symfony\Component\HttpFoundation\Response::class)) { + + $response = \Symfony\Component\HttpFoundation\Response::create($data); + $response->headers->set('Content-Type', $mime); + $response->headers->set('Content-Length', $length); + } else { header('Content-Type: ' . $mime);