cristianp6 / slim-json-api-helper
Slim3 JSON API Request & Response Helper inspired by jsonapi.org
2.0.1
2016-01-27 09:11 UTC
Requires
- php: >=5.5
- slim/slim: ~3
Requires (Dev)
- phpro/grumphp: ^0.7.1
- phpunit/phpunit: ^4.0
This package is not auto-updated.
Last update: 2024-11-09 19:51:02 UTC
README
Requirements
- PHP >= 5.5
Usage
use Slim\Http\Request as Request; use JsonApiHelper\Renderer; $app = new \Slim\App($settings); $container = $app->getContainer(); // register the json response and error handlers $jsonApiHelper = new JsonApiHelper\JsonApiHelper($app->getContainer()); $jsonApiHelper->registerResponseResult(); $jsonApiHelper->registerErrorHandlers(); $this->post('/users', function (Request $request, Response $response, $args) { $user_id = $request->getParam('user_id'); $this->result->data = [ 'user_id' => $user_id ]; $response = $this->result->render($response, 200); return $response; }); }