PHPackages                             ez-php/storage - 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. [Framework](/categories/framework)
4. /
5. ez-php/storage

ActiveLibrary[Framework](/categories/framework)

ez-php/storage
==============

File storage abstraction for the ez-php framework — local filesystem and S3-compatible drivers

1.0.1(1mo ago)00MITPHPPHP ^8.5CI passing

Since Mar 28Pushed 1mo agoCompare

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

READMEChangelogDependencies (8)Versions (2)Used By (0)

ez-php/storage
==============

[](#ez-phpstorage)

File storage abstraction for the ez-php framework.

Provides a unified interface (`put`, `get`, `delete`, `exists`, `url`) over pluggable drivers. Ships with a **LocalDriver** (filesystem) and an **S3Driver** (AWS S3 and S3-compatible APIs via cURL + AWS Signature V4). Integrates with `UploadedFile` from `ez-php/http`.

---

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

[](#installation)

```
composer require ez-php/storage
```

---

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

[](#configuration)

Add `config/storage.php` to your application:

```
return [
    'driver' => env('STORAGE_DRIVER', 'local'),

    'local' => [
        'root' => env('STORAGE_ROOT', storage_path('app')),
        'url'  => env('STORAGE_URL', ''),
    ],

    's3' => [
        'key'        => env('AWS_ACCESS_KEY_ID'),
        'secret'     => env('AWS_SECRET_ACCESS_KEY'),
        'region'     => env('AWS_DEFAULT_REGION', 'us-east-1'),
        'bucket'     => env('AWS_BUCKET'),
        'endpoint'   => env('AWS_ENDPOINT'),   // optional: MinIO, R2, etc.
        'url'        => env('AWS_URL'),         // optional: CDN base URL
        'url_expiry' => 3600,
    ],
];
```

Register the provider in `provider/modules.php`:

```
\EzPhp\Storage\StorageServiceProvider::class,
```

---

Usage
-----

[](#usage)

### Via static façade

[](#via-static-façade)

```
use EzPhp\Storage\Storage;

Storage::put('avatars/user-1.jpg', $imageBytes);
$data = Storage::get('avatars/user-1.jpg');
Storage::exists('avatars/user-1.jpg'); // true
Storage::url('avatars/user-1.jpg');    // public URL or presigned URL
Storage::delete('avatars/user-1.jpg');
```

### Storing an uploaded file

[](#storing-an-uploaded-file)

```
Storage::putUploadedFile('uploads/' . $file->originalName(), $file);
```

### Via dependency injection

[](#via-dependency-injection)

```
use EzPhp\Storage\StorageInterface;

class AvatarController
{
    public function __construct(private readonly StorageInterface $storage) {}

    public function upload(Request $request): Response
    {
        $file = $request->file('avatar');
        $this->storage->putUploadedFile('avatars/' . $file->originalName(), $file);
        // ...
    }
}
```

---

Drivers
-------

[](#drivers)

### LocalDriver

[](#localdriver)

Stores files under a configurable root directory. Creates nested directories automatically.

```
$driver = new LocalDriver('/var/www/storage', 'https://cdn.example.com');
$driver->put('docs/readme.txt', 'Hello');
$driver->url('docs/readme.txt'); // https://cdn.example.com/docs/readme.txt
```

### S3Driver

[](#s3driver)

Uploads and retrieves objects using cURL with AWS Signature Version 4. Works with AWS S3 and any S3-compatible service (MinIO, Cloudflare R2, DigitalOcean Spaces).

- `url()` returns a presigned GET URL (valid for `url_expiry` seconds)
- If a custom `url` (CDN) is configured, `url()` returns `{url}/{path}` instead
- Custom `endpoint` overrides the default `{bucket}.s3.{region}.amazonaws.com` host

```
$driver = new S3Driver('key', 'secret', 'eu-west-1', 'my-bucket');
$driver->put('report.pdf', file_get_contents('/tmp/report.pdf'));
$driver->url('report.pdf'); // presigned URL
```

---

Running Tests
-------------

[](#running-tests)

```
docker compose exec app composer full
```

S3 integration tests are skipped unless `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_BUCKET` are set in the environment.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

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

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (2 commits)")

---

Tags

phpfilesystemframeworks3storageez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-storage/health.svg)

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

PHPackages © 2026

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