How do I make a PATCH request in PHP using cURL?

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH'); should do it.


JSON PATCH would be better for data format since this format is designed for HTTP PATCH request. See https://www.rfc-editor.org/rfc/rfc6902 for the spec. The tutorial of Rails 4 show the example(http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#http-patch).

// https://www.rfc-editor.org/rfc/rfc6902#section-4
$data = '{ "op": "add", "path": "/a/b/c", "value": "foo" }';
$headers = array('Content-Type: application/json-patch+json');