Local AWS S3 for PHP Symfony development with Docker

Stefan Pöltl
2 min readSep 13, 2023

In this post I’m going to show you the simplest way to develop AWS S3 related software locally. Adobe created a lightweight server for this usecase that exposes the most common API functionality. You can easily integrate it in your local development stack via a Docker image that has the footprint of around 70 MB.

Docker setup

As usual for Docker based development you have two options to start the S3 Server:

  1. Run the container with plain Docker command:
docker run -p 9090:9090 -p 9191:9191 -e initialBuckets=my-bucket -t adobe/s3mock

2. Run the container with docker compose:

services:
s3mock:
image: adobe/s3mock
environment:
- initialBuckets=my-bucket
ports:
- 9090:9090
- 9191:9191

Basically the HTTP port 9090 is enough for local development purposes. The other one (9191) works for HTTPS.

Install AWS SDK

All we really need to execute S3 API calls is the AWS PHP SDK:

composer require aws/aws-sdk-php

Let’s try a basic test script with the list buckets command:

<?php

require_once __DIR__ . '/vendor/autoload.php';

putenv("AWS_ACCESS_KEY_ID=id");
putenv("AWS_SECRET_ACCESS_KEY=key");

$s3client = new \Aws\S3\S3Client([
'version' => 'latest',
'endpoint' => 'http://localhost:9090',
'region'…

--

--

Stefan Pöltl
Stefan Pöltl

No responses yet