Skip to content
Get Started for Free
To improve reliability, we’ve moved to a single, authenticated LocalStack for AWS image that requires an auth token. For more details on plans and pricing, see our pricing page.

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.

Was this page helpful?