jder / psr
A response builder for PSR
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/jder/psr
Requires
- php: ^8.1.0
- psr/http-message: ^2.0.0
Requires (Dev)
- nyholm/psr7: ^1.8.2
- nyholm/psr7-server: ^1.1.0
- phpstan/phpstan: ^2.1.33
- phpunit/phpunit: ^12.5.3
- slim/slim: ^4.15.1
- squizlabs/php_codesniffer: ^4.0.1
- vimeo/psalm: ^6.14.2
This package is auto-updated.
Last update: 2025-12-16 14:25:42 UTC
README
A response builder for PSR.
This package includes different response builders based on the JSON response structure specified in JSON Data Errors Response (JDER). With the builders, various kinds of responses can be created easily instead of sending plain text responses.
Installation
Install this package as a dependency in the project:
composer require jder/psr
Quick Start
To create a JSON response, use the following code:
use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; use Jder\Psr\Json\CreateJsonResponse; function route( Request $request, Response $response, ): Response { return CreateJsonResponse::success($response)->create(); }
And the response will be shown as below:
{
"success": true,
"data": null,
"errors": []
}
Documentation
For the documentation,please refer to the documentation.
Contributing
For contributing, please refer to the contributing guide.
License
This project is licensed under the terms of the MIT license.