Slim PHP and GET Parameters

后端 未结 9 497
猫巷女王i
猫巷女王i 2021-01-30 03:56

I\'m playing with Slim PHP as a framework for a RESTful API, and so far it\'s great. Super easy to work with, but I do have one question I can\'t find the answer to. How do I gr

9条回答
  •  无人及你
    2021-01-30 04:30

    I fixed my api to receive a json body OR url parameter like this.

    $data = json_decode($request->getBody()) ?: $request->params();
    

    This might not suit everyone but it worked for me.

提交回复
热议问题