Author: Manuel Lemos
Updated on: 2021-03-15
Posted on: 2021-03-15
Package: Laravel JSON Request Validation
JSON is nowadays a common format to serve HTTP responses with data values represented as text.
When an API application is only meant to serve JSON based responses, it is useful to refuse serving requests from clients that are not ready to take JSON based responses, like for instance requests from regular browsers that expect HTML pages.
This package provides a solution that can be used in Laravel based applications to refuse serving HTTP requests from clients that are not ready to handle JSON based responses.
About the Laravel JSON Request Validation Package
The package Laravel JSON Request Validation is one of the few PHP packages that was considered notable recently because it does something that is worth paying attention.
The basic purpose is: Disallow HTTP requests that do not accept JSON
Here follows in more detail what it does:
This class is a middleware that can disallow HTTP requests that do not accept JSON.
It checks the current HTTP request to check the values for the Accept header.
The class will return HTTP status 400 if the application/json MIME type is not in the headers that the client accepts.
Conclusion
The Laravel JSON Request Validation can be downloaded from download page or be installed using the PHP Composer tool following instructions in the Composer install instructions page.
This package was considered notable for implementing its benefits in a way that is worth noticing.
Notable PHP packages can be often considered innovative. If this package is also innovative, it can be nominated to the PHP Innovation Award and the author may win prizes and recognition for sharing innovative packages.
If you also developed your own notable or innovative packages consider sharing them, so you can also earn more visibility for your package as well nice prizes.
One nice prize that many PHP developers want and you may like is the PHP elePHPant mascot plush.
You need to be a registered user or login to post a comment
Login Immediately with your account on:
Comments:
No comments were submitted yet.