Using the Amazon SDK for PHP and Running PHP Examples
The Amazon SDK for PHP provides access to the API for Amazon S3 bucket and object operations. The SDK gives you the option of using the service's low-level API or using higher-level abstractions.
The SDK is available at Amazon SDK for PHP
The setup for using the Amazon SDK for PHP depends on your environment and how you want to run your application. To set up your environment to run the examples in this documentation, see the Amazon SDK for PHP Getting Started Guide.
Amazon SDK for PHP Levels
The Amazon SDK for PHP gives you the option of using a high-level or low-level API.
Low-Level API
The low-level APIs correspond to the underlying Amazon S3 REST operations, including the create, update, and delete operations on buckets and objects. The low-level APIs provide greater control over these operations. For example, you can batch your requests and run them in parallel. Or, when using the multipart upload API, you can manage the object parts individually. Note that these low-level API calls return a result that includes all of the Amazon S3 response details. For more information about the multipart upload API, see Uploading and copying objects using multipart upload.
High-Level Abstractions
The high-level abstractions are intended to simplify common use cases. For example,
for uploading large objects using the low-level API, you call
Aws\S3\S3Client::createMultipartUpload()
, call the
Aws\S3\S3Client::uploadPart()
method to upload the object parts, then call
the Aws\S3\S3Client::completeMultipartUpload()
method to complete the upload.
You can use the higher-level Aws\S3\\MultipartUploader
object that simplifies
creating a multipart upload instead.
As another example, when enumerating objects in a bucket, you can use the iterators feature of the Amazon SDK for PHP to return all of the object keys, regardless of how many objects you have stored in the bucket. If you use the low-level API, the response returns a maximum of 1,000 keys. If a bucket contains more than 1,000 objects, the result is truncated and you have to manage the response and check for truncation.
Running PHP Examples
To set up and use the Amazon S3 samples for version 3 of the Amazon SDK for PHP, see Installation in the Amazon SDK for PHP Developer Guide.