aporat/slim-json-helpers

This package is abandoned and no longer maintained. No replacement package was suggested.

Slim3 JSON Request & Response Helpers

1.0.0 2016-01-11 15:54 UTC

This package is not auto-updated.

Last update: 2017-11-07 11:08:38 UTC


README

Latest Stable Version Composer Downloads Build Status Code Coverage License

Requirements

  • PHP >= 5.5

Usage


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, $data, 200);
    return $response;

  });
}