Skip to content

cristianp6/slim-json-api-helper

Repository files navigation

slim-json-api-helper

Latest Stable Version Composer Downloads Build Status License

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;

  });
}

About

Slim3 JSON API Request & Response Helpers inspired by jsonapi.org

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages