shellphy/slim4-response

There is no license information available for the latest version (v1.0.1) of this package.

Installs: 18

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/shellphy/slim4-response

v1.0.1 2023-08-13 04:31 UTC

This package is auto-updated.

Last update: 2025-10-13 09:07:58 UTC


README

Import Package:

composer require "shellphy/slim4-response"

Usage:

use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Shellphy\Slim4Response\SlimBootstrapper;

$app = SlimBootstrapper::bootstrap();

$app->get('/', function (Request $request, Response $response, $args) {
    $response->getBody()->write("hello, world");
    return $response;
});

$app->get('/error', function (Request $request, Response $response, $args) {
    throw new \Exception("error", 400);
});

If you request GET /, response this:

{
    "code": 0,
    "msg": "success",
    "data": "hello, world"
}

If you request GET /error, response this:

{
    "code": 400,
    "msg": "error",
    "data": null
}