PHPackages                             yggdrasilcloud/storage-s3 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. yggdrasilcloud/storage-s3

ActiveSymfony-bundle[File &amp; Storage](/categories/file-storage)

yggdrasilcloud/storage-s3
=========================

Amazon S3 storage adapter bridge for YggdrasilCloud

v0.2.0(4mo ago)012MITPHPPHP ^8.4CI passing

Since Dec 12Pushed 4mo agoCompare

[ Source](https://github.com/YggdrasilCloud/storage-s3)[ Packagist](https://packagist.org/packages/yggdrasilcloud/storage-s3)[ RSS](/packages/yggdrasilcloud-storage-s3/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (13)Versions (4)Used By (0)

YggdrasilCloud Storage S3
=========================

[](#yggdrasilcloud-storage-s3)

Amazon S3 storage adapter bridge for [YggdrasilCloud](https://github.com/YggdrasilCloud/core).

This package provides S3 storage backend support for YggdrasilCloud applications, allowing you to store files in Amazon S3 or S3-compatible services (MinIO, DigitalOcean Spaces, etc.).

Installation
------------

[](#installation)

```
composer require yggdrasilcloud/storage-s3
```

The bridge is automatically discovered by Symfony via service tagging.

Configuration
-------------

[](#configuration)

### Environment Variables

[](#environment-variables)

Set the `STORAGE_DSN` environment variable in your `.env` file:

```
# Amazon S3 (with explicit credentials)
STORAGE_DSN=storage://s3?bucket=my-bucket&region=eu-west-1&key=AKIAIOSFODNN7EXAMPLE&secret=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

# Amazon S3 (using AWS SDK default credential chain - recommended)
STORAGE_DSN=storage://s3?bucket=my-bucket&region=eu-west-1

# MinIO (custom endpoint)
STORAGE_DSN=storage://s3?bucket=my-bucket&region=us-east-1&endpoint=http://localhost:9000&key=minioadmin&secret=minioadmin

# DigitalOcean Spaces
STORAGE_DSN=storage://s3?bucket=my-space&region=fra1&endpoint=https://fra1.digitaloceanspaces.com&key=YOUR_KEY&secret=YOUR_SECRET

# With optional prefix for all files
STORAGE_DSN=storage://s3?bucket=my-bucket&region=eu-west-1&prefix=photos/
```

### DSN Parameters

[](#dsn-parameters)

#### Required

[](#required)

- `bucket`: S3 bucket name
- `region`: AWS region (e.g., `eu-west-1`, `us-east-1`)

#### Optional

[](#optional)

- `endpoint`: Custom S3 endpoint for S3-compatible services (MinIO, DigitalOcean Spaces, etc.)
- `key`: AWS access key ID (if not provided, uses AWS SDK default credential chain)
- `secret`: AWS secret access key (required if `key` is provided)
- `prefix`: Key prefix for all stored files (e.g., `photos/`)
- `url_expiration`: Presigned URL expiration time in seconds (default: `3600` = 1 hour)

### MinIO (Local Development &amp; Self-Hosting)

[](#minio-local-development--self-hosting)

MinIO is an open-source S3-compatible object storage server perfect for:

- **Local development**: Test S3 integration without AWS costs
- **Self-hosting**: Run your own S3-compatible storage on-premises
- **CI/CD**: Integration tests with real S3 API

**Development setup**:

```
STORAGE_DSN=storage://s3?bucket=my-bucket&region=us-east-1&endpoint=http://localhost:9000&key=minioadmin&secret=minioadmin
```

**Production self-hosting**:

```
STORAGE_DSN=storage://s3?bucket=photos&region=us-east-1&endpoint=https://minio.example.com&key=YOUR_KEY&secret=YOUR_SECRET
```

MinIO is included in `compose.yaml` for local development. See [Development &amp; Testing](#development--testing) section.

### AWS Credentials

[](#aws-credentials)

The adapter supports multiple authentication methods:

1. **Explicit credentials in DSN** (not recommended for production):

    ```
    STORAGE_DSN=storage://s3?bucket=my-bucket&region=eu-west-1&key=XXX&secret=YYY
    ```
2. **AWS SDK default credential chain** (recommended):

    - Environment variables (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`)
    - AWS credentials file (`~/.aws/credentials`)
    - IAM role for EC2 instances
    - IAM role for ECS tasks

    ```
    # .env
    STORAGE_DSN=storage://s3?bucket=my-bucket&region=eu-west-1

    # Credentials via environment variables
    AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
    AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
    ```

Usage
-----

[](#usage)

Once configured, the S3 storage adapter is automatically used by YggdrasilCloud when the DSN driver is `s3`.

The core application will use the `FileStorageInterface` to interact with S3:

```
// In your application code (core)
$storage->save($stream, 'photos/abc123/image.jpg', 'image/jpeg', 12345);
$storage->exists('photos/abc123/image.jpg'); // true
$url = $storage->url('photos/abc123/image.jpg'); // Presigned URL
$stream = $storage->readStream('photos/abc123/image.jpg');
$storage->delete('photos/abc123/image.jpg');
```

S3 Bucket Configuration
-----------------------

[](#s3-bucket-configuration)

### CORS Configuration

[](#cors-configuration)

If you need to access files from a web browser, configure CORS on your S3 bucket:

```
[
    {
        "AllowedHeaders": ["*"],
        "AllowedMethods": ["GET", "HEAD"],
        "AllowedOrigins": ["https://your-app.com"],
        "ExposeHeaders": ["ETag"],
        "MaxAgeSeconds": 3000
    }
]
```

### Bucket Policy (Optional)

[](#bucket-policy-optional)

For public read access (not recommended for most use cases):

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicRead",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::my-bucket/*"
        }
    ]
}
```

Requirements
------------

[](#requirements)

- PHP 8.4+
- YggdrasilCloud Core
- AWS SDK for PHP 3.x

Development &amp; Testing
-------------------------

[](#development--testing)

**IMPORTANT**: All commands must be run via Docker Compose to ensure PHP 8.4 compatibility.

### Setup

[](#setup)

```
# Start MinIO (S3-compatible local storage)
docker compose up -d minio

# Install dependencies (runs in ephemeral container)
docker compose run --rm app composer install
```

### Local S3 Testing with MinIO

[](#local-s3-testing-with-minio)

MinIO is included in the Docker setup for local development and testing.

**Access MinIO Console**:

- Username: `minioadmin`
- Password: `minioadmin`

**Test configuration** (`.env.test`):

```
STORAGE_DSN=storage://s3?bucket=test-bucket&region=us-east-1&endpoint=http://minio:9000&key=minioadmin&secret=minioadmin
```

**Create test bucket** (via MinIO Console or mc CLI):

```
# Using mc CLI inside MinIO container
docker compose exec minio mc alias set local http://localhost:9000 minioadmin minioadmin
docker compose exec minio mc mb local/test-bucket
```

### Quick Commands

[](#quick-commands)

```
# Run all quality checks + tests
docker compose run --rm app composer all

# Run code quality checks only (cs-fixer + phpstan)
docker compose run --rm app composer qual

# Run CI checks (lint + cs-fixer + phpstan + tests)
docker compose run --rm app composer ci
```

### Individual Tools

[](#individual-tools)

```
# PHP Lint
docker compose run --rm app composer lint

# Code style (fix)
docker compose run --rm app composer cs:fix

# Code style (check)
docker compose run --rm app composer cs:check

# Static analysis (PHPStan level 9)
docker compose run --rm app composer stan

# Unit tests only
docker compose run --rm app composer test

# Functional tests (requires MinIO running)
docker compose up -d minio
docker compose run --rm app vendor/bin/phpunit --testsuite=Functional

# All tests (unit + functional)
docker compose run --rm app vendor/bin/phpunit

# Mutation testing (Infection)
docker compose run --rm app composer infection
```

### Without Docker (Not Recommended)

[](#without-docker-not-recommended)

If you have PHP 8.4 installed locally, you can run commands directly:

```
composer install
composer all
```

### Git Hooks (GrumPHP)

[](#git-hooks-grumphp)

GrumPHP automatically runs quality checks on every commit:

- PHP Lint
- PHP CS Fixer
- PHPStan
- PHPUnit tests
- Infection mutation testing

Hooks are automatically installed after `composer install`.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

Contributing
------------

[](#contributing)

Contributions are welcome! Please open an issue or submit a pull request.

Security
--------

[](#security)

If you discover a security vulnerability, please email  instead of opening a public issue.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance78

Regular maintenance activity

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

147d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a864b67689c18f73803e34b6c4e269ab08395067ad635e1382ed96cc76f596a0?d=identicon)[roukmoute](/maintainers/roukmoute)

---

Top Contributors

[![roukmoute](https://avatars.githubusercontent.com/u/2140469?v=4)](https://github.com/roukmoute "roukmoute (28 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/yggdrasilcloud-storage-s3/health.svg)

```
[![Health](https://phpackages.com/badges/yggdrasilcloud-storage-s3/health.svg)](https://phpackages.com/packages/yggdrasilcloud-storage-s3)
```

###  Alternatives

[vich/uploader-bundle

Ease file uploads attached to entities

1.9k25.9M114](/packages/vich-uploader-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[symfony/ux-dropzone

File input dropzones for Symfony Forms

541.5M4](/packages/symfony-ux-dropzone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
