title: AWS S3 cannot delete objects in bucket via PHP SDK
body: <p>I'm using AWS SDK for PHP (Laravel) and I'm trying to delete a S3 bucket with all the objects inside. Here is my code:</p>
  
  <pre><code>public function deleteBucket($syndcateid){
      $s3client = AWS::createClient('s3');
      $bucket = env('S3_BUCKET')."/syndcate-uploads/syndcate-".$syndcateid;
      $listObjectsParams = ['Bucket' =&gt; $bucket];
      $batchDelete = BatchDelete::fromListObjects($s3client, $listObjectsParams);
      $batchDelete-&gt;delete();
      $s3client-&gt;deleteBucket(array('Bucket' =&gt; $bucket));
      $s3client-&gt;waitUntil('BucketNotExists', array('Bucket' =&gt; $bucket));
  }
  </code></pre>
  
  <p>And when I run this code, I get the error:</p>
  
  <blockquote>
    <p>Error executing \"ListObjects\" on \"<a href="https://s3-us-west-2.amazonaws.com/syndcate-media%2Fsyndcate-uploads%2Fsyndcate-32?delimiter=%2F&amp;encoding-type=url" rel="nofollow">https://s3-us-west-2.amazonaws.com/syndcate-media%2Fsyndcate-uploads%2Fsyndcate-32?delimiter=%2F&amp;encoding-type=url</a>\"; AWS HTTP error: Client error: <code>GET https://s3-us-west-2.amazonaws.com/syndcate-media%2Fsyndcate-uploads%2Fsyndcate-32?delimiter=%2F&amp;encoding-type=url</code> resulted in a <code>403 Forbidden</code> response:\n\n<Code>SignatureDoesNotMatch</Code>The request signature we calcul (truncated...)\n SignatureDoesNotMatch (client): The request signature we calculated does not match the signature you provided. Check your key and signing method. - \n<Code>SignatureDoesNotMatch</Code>The request signature we calculated does not match the signature you provided. Check your key and signing method.</p>
  </blockquote>
  
  <p>Basically it is a <code>SignatureDoesNotMatch</code> error, and the reason its happening is, the slashes in the URL are not being decoded, as the requested URL (<code>https://s3-us-west-2.amazonaws.com/syndcate-media%2Fsyndcate-uploads%2Fsyndcate-32</code>) appears to have <code>%2F</code> instead of slashes. </p>
  
  <p>I tried with the root bucket (no slashes), and it worked.</p>
  
  <p>Any idea how to get the bucket name right ?</p>