PHPackages                             silverstripe/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. silverstripe/s3

ActiveSilverstripe-vendormodule[File &amp; Storage](/categories/file-storage)

silverstripe/s3
===============

Adds SilverStripe support for using the S3 adapter for Flysystem

5.0.1(8mo ago)20297.0k↓18.4%27[3 issues](https://github.com/silverstripe/silverstripe-s3/issues)1BSD-3-ClausePHP

Since Apr 14Pushed 4mo ago11 watchersCompare

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

READMEChangelog (10)Dependencies (2)Versions (25)Used By (1)

silverstripe-s3
===============

[](#silverstripe-s3)

SilverStripe module to store assets in S3 rather than on the local filesystem.

```
composer require silverstripe/s3
```

Warning

This module does not currently implement any kind of bucket policy for protected assets. It is up to you to implement this yourself using AWS bucket policy.

Caution

This replaces the built-in local asset store that comes with SilverStripe with one based on S3. Any files that had previously been uploaded to an existing asset store will be unavailable (though they won't be lost - just run `composer remove silverstripe/s3` to remove the module and restore access).

Environment setup
-----------------

[](#environment-setup)

The module requires a few environment variables to be set.

- `AWS_REGION`: The AWS region your S3 bucket is hosted in (e.g. `eu-central-1`)
- `AWS_BUCKET_NAME`: The name of the S3 bucket to store assets in.

If running outside of an EC2 instance it will be necessary to specify an API key and secret.

- `AWS_ACCESS_KEY_ID`: Your AWS access key that has access to the bucket you want to access
- `AWS_SECRET_ACCESS_KEY`: Your AWS secret corresponding to the access key

**Example YML Config when running outside of EC2:**

```
---
Only:
    envvarset: AWS_BUCKET_NAME
After:
    - "#assetsflysystem"
---
SilverStripe\Core\Injector\Injector:
    Aws\S3\S3Client:
        constructor:
            configuration:
                region: "`AWS_REGION`"
                version: latest
                credentials:
                    key: "`AWS_ACCESS_KEY_ID`"
                    secret: "`AWS_SECRET_ACCESS_KEY`"
```

(Optional) CDN Implementation
-----------------------------

[](#optional-cdn-implementation)

If you're serving assets from S3, it's recommended that you utilize CloudFront. This improves performance and security over exposing from S3 directly.

Once you've set up your CloudFront distribution, ensure that assets are reachable within the `assets` directory of the cdn (for example; ) and set the following environment variable:

- `AWS_PUBLIC_CDN_PREFIX`: Your CloudFront distribution domain that has access to the bucket you want to access

For example, adding this to your `.env`:

`AWS_PUBLIC_CDN_PREFIX='https://cdn.example.com/'`

will change your URLs from something like:

`https://s3.ap-southeast-2.amazonaws.com/mycdn/public/example/live/assets/Uploads/file.jpg`

to something like:

`https://cdn.example.com/assets/Uploads/file.jpg`

You can override the default `/assets/` path by declaring the PublicCDNAdapter constructor, with the parameter for the `cdnAssetsDir` set to a string of your folder name. In your `app/_config/assets.yml` file add the following:

```
---
Name: app#silverstripes3-cdn
Only:
    envvarset: AWS_PUBLIC_CDN_PREFIX
After:
    - "#assetsflysystem"
    - "#silverstripes3-flysystem"
---
SilverStripe\Core\Injector\Injector:
    SilverStripe\Assets\Flysystem\PublicAdapter:
        class: SilverStripe\S3\Adapter\PublicCDNAdapter
        constructor:
            s3Client: '%$Aws\S3\S3Client'
            bucket: "`AWS_BUCKET_NAME`"
            prefix: "`AWS_PUBLIC_BUCKET_PREFIX`"
            visibility: null
            mimeTypeDetector: null
            cdnPrefix: "`AWS_PUBLIC_CDN_PREFIX`"
            options: []
            cdnAssetsDir: "cms-assets" # example of a custom assets folder name
```

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

[](#configuration)

Assets are classed as either 'public' or 'protected' by SilverStripe. Public assets can be freely downloaded, whereas protected assets (e.g. assets not yet published) shouldn't be directly accessed.

The module supports this by streaming the contents of protected files down to the browser via the web server (as opposed to linking to S3 directly) by default. To ensure that protected assets can't be accessed, ensure you setup an appropriate bucket policy (see below for an untested example).

### Configuring S3

[](#configuring-s3)

The 'protected' S3 asset store should be protected using standard AWS IAM policies that disallow all access to anonymous users, but still allow the action `s3:GetObject` for both public and protected files. Protected files will be streamed from AWS, so they do not need to be accessed by users directly. Therefore, something similar to the following bucket policy may be useful.

Make sure you replace `` below with the appropriate values.

**Note:** The below policy has not been extensively tested - feedback welcome.

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

If you are utilizing a CloudFront distribution for your public assets, you will have the option of securing your S3 bucket against all public access while still allowing access to your `public` files via your CloudFront distribution and access to your `protected` files via signed URLs.

For developers
--------------

[](#for-developers)

Read [Setting up a local sandbox for developing the Silverstripe S3 module](doc/en/setting-local-dev-environment.md) if you wish to do some local development.

### Performance

[](#performance)

This module comes with a basic in-memory cache for calls to S3. It is highly recommended to add an additional layer of caching to achieve the best results.

See [https://docs.silverstripe.org/en/5/developer\_guides/performance/caching/](https://docs.silverstripe.org/en/5/developer_guides/performance/caching/) for more information.

```
Name: silverstripes3-flysystem-memcached
After:
    - "#silverstripes3-flysystem"
---
SilverStripe\Core\Injector\Injector:
    MemcachedClient:
        class: "Memcached"
        calls:
            - [addServer, ["localhost", 11211]]
    MemcachedCacheFactory:
        class: 'SilverStripe\Core\Cache\MemcachedCacheFactory'
        constructor:
            client: "%$MemcachedClient"
    SilverStripe\Core\Cache\CacheFactory: "%$MemcachedCacheFactory"
```

Uninstalling
------------

[](#uninstalling)

Run `composer remove silverstripe/s3` to remove the module.

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance67

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community31

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~153 days

Recently: every ~97 days

Total

21

Last Release

246d ago

Major Versions

0.4.0 → 1.0.02019-04-09

1.x-dev → 2.0.02023-10-27

2.0.0 → 3.0.02023-11-30

3.0.1 → 4.0.02024-06-13

4.0.3 → 5.0.02025-08-21

### Community

Maintainers

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

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

![](https://www.gravatar.com/avatar/afbb3dcc9ef29c1a6eedd6addcae5fce9ab1271915a85a4c349301b71237368d?d=identicon)[silverstripe-machine01](/maintainers/silverstripe-machine01)

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

---

Top Contributors

[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (22 commits)")[![obj63mc](https://avatars.githubusercontent.com/u/443120?v=4)](https://github.com/obj63mc "obj63mc (16 commits)")[![madmatt](https://avatars.githubusercontent.com/u/893117?v=4)](https://github.com/madmatt "madmatt (10 commits)")[![filiplikavcan](https://avatars.githubusercontent.com/u/1244233?v=4)](https://github.com/filiplikavcan "filiplikavcan (4 commits)")[![zanderwar](https://avatars.githubusercontent.com/u/13566916?v=4)](https://github.com/zanderwar "zanderwar (3 commits)")[![DanielHurdMint](https://avatars.githubusercontent.com/u/167372126?v=4)](https://github.com/DanielHurdMint "DanielHurdMint (1 commits)")[![NightJar](https://avatars.githubusercontent.com/u/778003?v=4)](https://github.com/NightJar "NightJar (1 commits)")[![samandeggs](https://avatars.githubusercontent.com/u/5750792?v=4)](https://github.com/samandeggs "samandeggs (1 commits)")[![tim-lar](https://avatars.githubusercontent.com/u/2898709?v=4)](https://github.com/tim-lar "tim-lar (1 commits)")[![mpeel-akqa](https://avatars.githubusercontent.com/u/130476500?v=4)](https://github.com/mpeel-akqa "mpeel-akqa (1 commits)")[![emteknetnz](https://avatars.githubusercontent.com/u/4809037?v=4)](https://github.com/emteknetnz "emteknetnz (1 commits)")[![Fexiven](https://avatars.githubusercontent.com/u/48439988?v=4)](https://github.com/Fexiven "Fexiven (1 commits)")[![kevingroeger](https://avatars.githubusercontent.com/u/54183086?v=4)](https://github.com/kevingroeger "kevingroeger (1 commits)")[![medv](https://avatars.githubusercontent.com/u/1631737?v=4)](https://github.com/medv "medv (1 commits)")

---

Tags

filesystems3awssilverstripe

### Embed Badge

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

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k639.1M2.2k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M790](/packages/league-flysystem-aws-s3-v3)[league/flysystem-async-aws-s3

AsyncAws S3 filesystem adapter for Flysystem.

2610.5M31](/packages/league-flysystem-async-aws-s3)

PHPackages © 2026

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