shellphy/slim4-response

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

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

This package is auto-updated.

Last update: 2025-06-13 08:20:51 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
}