Crell / ApiProblem

A simple implementation of the api-problem specification. Includes PSR-15 support.
MIT License
239 stars 21 forks source link

Issue #26 support rendering using json_encode() #29

Closed judgej closed 5 years ago

judgej commented 5 years ago

Simple JsonSerializable support.

This is useful in frameworks such as Laravel or Lumen that will accept any object as a HTTP response payload that can be JSON serialised.

Resolves #26

judgej commented 5 years ago

I was in two minds about adding __toString() support too, but since the desired serialisation could be either JSON or XML, I felt it better not to force the decision of which it is onto developers.

judgej commented 5 years ago

The docs - I forgot the docs. Does it need a mention, or will it just be obvious to people who need it, and ignored by people who don't?

Crell commented 5 years ago

Hm, the README could use some updating anyway as it's also missing the middleware support. If you want to take a crack at it in another PR, go for it. If not I'll try to update the README in the near-ish future before tagging a new release.