title: How to load AWS SDK into CakePHP?
body: <p>I'm creating a S3 plugin for my app. In <code>app/Plugin/S3/Controller/Component/S3Component.php</code> I have these:</p>
  
  <pre><code>&lt;?php 
  
  App::import('Vendor', 'aws/aws-autoloader');
  
  use Aws\S3\S3Client;
  
  class S3Component extends Component {
  
      public function loadS3 () {
          $s3 = S3Client::factory(array(
              'key' =&gt; '',
              'secret' =&gt; ''
          ));
          return $s3;
      }
  
  }
  </code></pre>
  
  <p>In my app's controller, I call it using <code>$s3 = $this-&gt;S3-&gt;loadS3();</code></p>
  
  <p>It throws the error <code>Error: Class 'Aws\S3\S3Client' not found</code></p>
  
  <p>I tried adding the line: <code>App::uses('Vendor', 'aws/Aws/S3/S3Client');</code> to the component class, and removed <code>use Aws\S3\S3Client;</code>. It shows <code>Error: Class 'S3Client' not found</code></p>
  
  <p>The AWS SDK in in the folder <code>app/Plugin/S3/Vendor/aws</code></p>
  
  <p>I'm loading the S3 object with reference to: <a href="http://docs.aws.amazon.com/aws-sdk-php/guide/latest/quick-start.html#factory-method">http://docs.aws.amazon.com/aws-sdk-php/guide/latest/quick-start.html#factory-method</a></p>
  
  <p><strong>Solution:</strong></p>
  
  <p>This is how my component looks like now with the help of @akirk.</p>
  
  <pre><code>&lt;?php 
  
  ini_set('include_path', ROOT . DS . 'lib' . PATH_SEPARATOR . ini_get('include_path'). PATH_SEPARATOR . ROOT .DS . 'app/Plugin/S3/Vendor/aws');
  
  require ROOT . DS . 'app/Plugin/S3/Vendor/aws/aws-autoloader.php';
  
  use Aws\S3\S3Client;
  
  class S3Component extends Component {
  
      public function loadS3 () {
          $s3 = S3Client::factory(array(
              'key' =&gt; '',
              'secret' =&gt; ''
          ));
          return $s3;
      }
  
  }
  </code></pre>