how to send JSON data to an API using PUT method via cURL/PHP
From what I understand, using PUT this way doesn't behave the way you would expect. Try this instead:
...if($method == 'POST'){ curl_setopt($ch, CURLOPT_POST, true);} elseif( $method == 'PUT'){ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');...
Reference: Handling PUT/DELETE arguments in PHP