I'm struggling to create working PUT routes in my Lumen API. My requests reach the correct route, but I'm unable to access any values through $request->all().
I've figured out that PHP needs to read the php://input stream to get the PUT body. This is done in the getContent() function of Symfony\Component\HttpFoundation\Request. However, this function is called multiple times and since the input buffer is emptied when read, the data is not present when I need it.
I also found out that when I set my Content-Type header to text/plain I can successfully print $request->json(), but when I set it to application/json the object is empty.
Any ideas?
PS: I'm aware that for HTML requests you should add the _method parameter, but since I'm not doing my requests through HTML the parameter shouldn't be needed.
Edit:
My route:
$app->put('settings', 'SettingController@update');
My controller:
class SettingController extends Controller
{
public function update(Request $request)
{
print_r($request->all());
}
}
$api->put('settings', 'SettingController@update');. In the update method I simply doprint_r($request->all()), which is empty. I'm using the dingo package by the way. - Martijn