I am using the Slim framework with PHP to create a RESTful API for my app. However, I assumed that the framework would have some way of creating easier JSON outputs rather than
[BEFORE]: Content-Type text/html; charset=UTF-8
Not working with SOAPUI JSON :(
$this->get('get_all', function ($req, $res, $args) {
$um = new UserModel();
return $res
->withHeader('Content-Type', 'application/json')
->getBody()
->write(
json_encode(
$um->get_all()
)
);
});
[AFTER]: Content-Type application/json;charset=utf-8
Working with SOAPUI JSON ;)
$this->get('get_all', function ($req, $res, $args) {
$um = new UserModel();
return $res
->withHeader('Content-type', 'application/json;charset=utf-8')
->withJson($um->get_all());