phprest

Get PATCH request data in PHP


I need to make a PATCH request to a PHP application.

How can I get the data from that PATCH request inside that application?

If I had to do it with a POST, it would just be a simple access to the global $_POST variable.


Solution

  • You can get data with php://input stream wrapper:

    $data = file_get_contents('php://input');
    

    Also make sure your web server supports PATCH requests, some are configured to respond only to GET and POST.