title: JSON PUT request using Slim framework
body: <p>I am trying to make a PUT request to Slim using the following code:</p>
  
  <pre><code> &lt;script type = "text/javascript"&gt;
   function submitform() {
     var url = '/users/' + $('#user_id').val();
     $('#myform').attr('action', url);
     var data = JSON.stringify({"value": $('#user_data').val()});
     $('&lt;input type="hidden" name="json"/&gt;').val(data).appendTo('#myform');
     $("#myform").submit();
     }
   &lt;/script&gt;
  
   &lt;form id = "myform" method="post"&gt;
   id:   &lt;input type = "text" id = "user_id"&gt;
   data: &lt;input type = "text" name = "value" id = "user_data"&gt;
   &lt;input type="hidden" name="_METHOD" value="PUT"/&gt;
   &lt;input type = "button" value = "submit" onClick='submitform()'&gt;
   &lt;/form&gt;
  </code></pre>
  
  <p>My index.php file contains:</p>
  
  <pre><code>$app-&gt;put('/users/:id', 'update');
  function update($id) {
    $jsonmessage = \Slim\Slim::getInstance()-&gt;request();
    $message = json_decode($jsonmessage-&gt;getBody());
    // what do I put here ????
    }
  </code></pre>
  
  <p>What should I put in place of the ???? to retrieve the value parameter.
  I can see it if I use $_POST['json'] but I don't think this is REST compliant.
  Everything else I've tried, such as $message->value, doesn't work (returns nothing).</p>
  
  <p>Thanks. </p>
  
  <p>UPDATE:</p>
  
  <p>Somebody from the Slim forum provided the following answer:</p>
  
  <pre><code>$json = $jsonmessage-&gt;put('json');
  $message = json_decode($json);
  </code></pre>