Skip to content
Get Started for Free
We're moving toward a unified LocalStack for AWS image, updating how access works. For details on timing and impact please refer to this blog post.

AWS PHP

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.

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.