Slim JSON Outputs

前端 未结 17 1892
一整个雨季
一整个雨季 2021-01-30 09:00

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

17条回答
  •  独厮守ぢ
    2021-01-30 09:55

    This is how I do it in slim version 2

    $app->response->headers->set("Content-Type", 'application/json');
    return $app->response->write(json_encode([
        'status' => true,
        'message' => 'Your message'
    ]));
    

提交回复
热议问题