PHP

How to use the PHP AWS SDK with LocalStack.

Overview

The AWS SDK for PHP, like other AWS SDKs, lets you set the endpoint when creating resource clients, which is the preferred way of integrating the PHP SDK with LocalStack.

Example

Here is an example of how to create an S3Client with the endpoint set to LocalStack.

  1. use Aws\S3\S3Client;
  2. use Aws\Exception\AwsException;
  3. // Configuring S3 Client
  4. $s3 = new Aws\S3\S3Client([
  5. 'version' => '2006-03-01',
  6. 'region' => 'us-east-1',
  7. // Enable 'use_path_style_endpoint' => true, if bucket name is non DNS compliant
  8. 'use_path_style_endpoint' => true,
  9. 'endpoint' => 'http://s3.localhost.localstack.cloud:4566',
  10. ]);

A full example can be found in our samples repository.

Resources

Last modified October 11, 2021: minor: rename folder Integrations->integrations (68c86019)