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

0.1.0 2025-12-16 14:07 UTC

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.