PHP code example of org_heigl / slim-json-helpers
1. Go to this page and download the library: Download org_heigl/slim-json-helpers 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/ */
org_heigl / slim-json-helpers example snippets
use Slim\Http\Request as Request;
use JsonHelpers\Renderer as JsonRenderer;
$app = new \Slim\App($settings);
$container = $app->getContainer();
// register the json response and error handlers
$jsonHelpers = new JsonHelpers\JsonHelpers($app->getContainer());
$jsonHelpers->registerResponseView();
$jsonHelpers->registerErrorHandlers();
$this->post('/users', function (Request $request, Response $response, $args)
{
$user_id = $request->getParam('user_id');
$data = [
'user_id' => $user_id
];
$response = $this->view->render($response, 200, $data);
return $response;
});
}