zend-diactoros icon indicating copy to clipboard operation
zend-diactoros copied to clipboard

Add ImageResponse?

Open RalfEggert opened this issue 9 years ago • 9 comments

How about adding an Zend\Diactoros\Response\ImageResponse that supports the most common file types like JPG, GIF and PNG? How could this be archieved?

RalfEggert avatar Jan 27 '16 08:01 RalfEggert

I would say let Diactoros be safe from all these and only rely on the psr-7 interfaces.

If we need, we can add to Diactoros\Extras or something.

You may ask, what is the advantage ?

If we do add more helper function people will use those, and the purpose of switching between psr-7 packages will get into trouble. Lets not bring it due to the same.

harikt avatar Jan 28 '16 17:01 harikt

@harikt

Thanks for your feedback. For the same reason then Zend\Diactoros\Response\HtmlResponse or Zend\Diactoros\Response\JsonResponse should be deleted.

RalfEggert avatar Jan 28 '16 19:01 RalfEggert

I don't know that will happen due to BC break. But I think yes.

harikt avatar Jan 29 '16 04:01 harikt

But these Reponse classes are really useful in the context of a Zend\Expressive application. If you want to remove them from Zend\Diactoros where should they be placed? Moving them to a different Zend\Diactoros package won't really solve the problem. People will still use them.

RalfEggert avatar Jan 29 '16 05:01 RalfEggert

@RalfEggert I don't know the whole edge cases, but this is what I was thinking.

Zend\Diactoros\Extras can be type hinted to psr-7 response interfaces. So that means not just diactors can use these, but also any psr-7 responses.

But I understand that is not so simple, as the current ones are doing.

return new [JsonResponse](https://github.com/zendframework/zend-diactoros/blob/master/src/Response/JsonResponse.php)();

So I don't have a real answer for the current time. But I will think about the same.

harikt avatar Jan 29 '16 05:01 harikt

I want to keep them. I don't see how they reduce compatibility with PSR7. Those helper methods still create a PSR7 ResponseInterface. We typically only use those helper classes on controllers (which are tied to a framework like Expressive, so it definitely makes sense to use them), but on other layer we still typehint against ResponseInterface.

Those are just shortcuts that are super convenient to use. -1 for removing them.

bakura10 avatar Feb 08 '16 09:02 bakura10

@bakura10

I have the same opinion that they are very useful and should be kept.

But what about the Zend\Diactoros\Response\ImageResponse I suggested?

RalfEggert avatar Feb 08 '16 18:02 RalfEggert

I feel we should support anything that is often required. I'm not sure about ImageResponse. What is the use case? You return an image after processing in the back-end?

bakura10 avatar Feb 08 '16 20:02 bakura10

This repository has been closed and moved to laminas/laminas-diactoros; a new issue has been opened at https://github.com/laminas/laminas-diactoros/issues/28.

weierophinney avatar Dec 31 '19 22:12 weierophinney