PHPackages                             dnsk-work/twill-r2 - 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. dnsk-work/twill-r2

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

dnsk-work/twill-r2
==================

Twill fixes for Cloudflare R2 and S3-compatible object storage (URL generation, policy signing, safe deletion)

v1.0.2(1mo ago)01MITPHPPHP ^8.1

Since Jun 22Pushed 2mo agoCompare

[ Source](https://gitlab.com/dnsk.work/twill-r2)[ Packagist](https://packagist.org/packages/dnsk-work/twill-r2)[ Docs](https://gitlab.com/dnsk.work/twill-r2)[ RSS](/packages/dnsk-work-twill-r2/feed)WikiDiscussions main Synced 1w ago

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

Twill R2 — Cloudflare R2 &amp; S3 fixes for Laravel Twill
=========================================================

[](#twill-r2--cloudflare-r2--s3-fixes-for-laravel-twill)

Fixes three bugs in [Laravel Twill](https://twillcms.com) that surface when using Cloudflare R2 or any S3-compatible storage with a custom endpoint. Covers the media library, file library, and Fine Uploader policy signing.

What it fixes
-------------

[](#what-it-fixes)

### 1. Public URL generation (media library &amp; file library)

[](#1-public-url-generation-media-library--file-library)

Laravel Twill overwrites the disk's `url` config to a local path when `file_library.endpoint_type` is `"local"`, breaking all public file URLs on Cloudflare R2. This package reads `FILE_LIBRARY_PUBLIC_URL` instead, decoupling URL generation from the disk config entirely.

### 2. Fine Uploader S3 policy signing

[](#2-fine-uploader-s3-policy-signing)

Twill's `SignS3Upload::isValid()` compares `parsedMaxSize` against `(string)null`, which always fails when Fine Uploader includes a `content-length-range` condition in the upload policy — blocking all file and media uploads. This package validates by checking the `bucket` condition instead, keeping the full HMAC-SHA256 v4 signing logic intact.

### 3. Safe media &amp; file deletion

[](#3-safe-media--file-deletion)

Twill's `afterDelete()` calls `Storage::disk()->files()` to clean up empty parent directories. On Cloudflare R2, a malformed `AWS_ENDPOINT` (bucket name included) causes `ListObjectsV2` to return `NoSuchKey`, which throws `UnableToListContents` and rolls back the DB delete transaction — leaving orphaned records in `twill_medias` and `twill_files`. This package wraps both operations in `try/catch` so the database record is always deleted.

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

[](#installation)

```
composer require dnsk-work/twill-r2
```

The service provider is auto-discovered by Laravel. No other steps are needed for fixes 2 and 3.

For fix 1 (public URL generation), add to `config/filesystems.php`:

```
'file_library_public_url' => env('FILE_LIBRARY_PUBLIC_URL'),
```

Then set `FILE_LIBRARY_PUBLIC_URL` in your `.env` to the public base URL of your R2 bucket (e.g. `https://files.example.com`). The override only activates when this key is present — if it's not set, Twill's default behaviour is preserved.

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

[](#requirements)

- PHP 8.1+
- Laravel Twill 3.x

License
-------

[](#license)

MIT

---

Made by [DNSK.WORK](https://dnsk.work), a [UI/UX agency](https://dnsk.work).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance89

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

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

Total

3

Last Release

32d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97341bc4ae531e231e628ed6bc237cb72afd375af4d8a62b629648cbfd19c9b6?d=identicon)[alexhalchenko](/maintainers/alexhalchenko)

---

Tags

laravels3storagemedia librarytwillcloudflare-r2file libraryfine\_uploader

### Embed Badge

![Health badge](/badges/dnsk-work-twill-r2/health.svg)

```
[![Health](https://phpackages.com/badges/dnsk-work-twill-r2/health.svg)](https://phpackages.com/packages/dnsk-work-twill-r2)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.1k](/packages/league-flysystem-aws-s3-v3)[mwguerra/filemanager

A full-featured file manager package for Laravel and Filament v5 with dual operating modes, drag-and-drop uploads, S3/MinIO support, and comprehensive security features.

8020.3k3](/packages/mwguerra-filemanager)

PHPackages © 2026

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