PHP code example of shellphy / slim4-response
1. Go to this page and download the library: Download shellphy/slim4-response library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shellphy / slim4-response example snippets
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);
});