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.

use Aws\S3\S3Client;
use Aws\Exception\AwsException;

// Configuring S3 Client
$s3 = new Aws\S3\S3Client([
    'version' => '2006-03-01',
    'region' => 'us-east-1',
    // Enable 'use_path_style_endpoint' => true, if bucket name is non DNS compliant
    'use_path_style_endpoint' => true,
    'endpoint' => 'http://s3.localhost.localstack.cloud:4566',
]);

A full example can be found in our samples repository.

Resources