Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Zend Framework 101: Zend_Service_Amazon_S3

Connecting to Amazon S3

Now that you have an AWS Key and an AWS Secret Key you can connect to Amazon S3. To access Amazon S3 with the Zend Framework you will be using the class Zend_Service_Amazon_S3.

For the purposes of this article we'll assume your AWS Key is stored in a variable called $awsKey, and your AWS Secret Key is stored in a variable called $awsSecretKey. The following example shows how to specify your keys each time you instantiate the class.

Listing 1 Instantiating Zend_Service_Amazon_S3 with keys (listing-1.php)
    $s3 = new Zend_Service_Amazon_S3($awsKey, $awsSecretKey);
Listing 2 Specifying AWS keys ahead of time (listing-2.php)
    Zend_Service_Amazon_S3::setKeys($awsKey, $awsSecretKey);
    $s3 = new Zend_Service_Amazon_S3();
    $anotherS3 = new Zend_Service_Amazon_S3();

In This Article

Bonus listings: 2 available