New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

reusser/laravel-cloudflare-r2

Cloudflare R2 integration for Laravel's Storage API
11,967 10
Install
composer require reusser/laravel-cloudflare-r2
Latest Version:1.0.2
PHP:^8.2
Laravel:10 – 13
License:MIT
Last Updated:Apr 21, 2026
Links: GitHub  ·  Packagist
Maintainer: reusserdesign

Cloudflare R2 integration for Laravel's Storage API

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Cloudflare R2 integration for Laravel's Storage API

Installation

You can install the package via composer:

composer require reusser/laravel-cloudflare-r2

Option 1: Use a new Disk

Add this to the disks section of config/filesystems.php:

        'r2' => [
            'driver' => 'r2',
            'key' => env('R2_ACCESS_KEY_ID'),
            'secret' => env('R2_SECRET_ACCESS_KEY'),
            'region' => env('R2_DEFAULT_REGION', 'us-east-1'),
            'bucket' => env('R2_BUCKET'),
            'url' => env('R2_URL'),
            'endpoint' => env('R2_ENDPOINT', false),
            'use_path_style_endpoint' => env('R2_USE_PATH_STYLE_ENDPOINT', false),
            'throw' => false,
        ],

And fill out these in your .env:

R2_URL=https://some-worker.randomid.workers.dev
R2_ENDPOINT=https://randomid.r2.cloudflarestorage.com
R2_ACCESS_KEY_ID=random-key
R2_SECRET_ACCESS_KEY=random-secret
R2_BUCKET=bucket
R2_DEFAULT_REGION=us-east-1
R2_USE_PATH_STYLE_ENDPOINT=false

Option 2: Use S3 Disk

Change your s3 disk to the R2 driver in config/filesystems.php:

        's3' => [
            'driver' => 'r2',
            ...

And fill out these in your .env:

AWS_URL=https://some-worker.randomid.workers.dev
AWS_ENDPOINT=https://random-id.r2.cloudflarestorage.com
AWS_ACCESS_KEY_ID=random-key
AWS_SECRET_ACCESS_KEY=random-secret
AWS_BUCKET=some-bucket
AWS_DEFAULT_REGION=us-east-1
AWS_USE_PATH_STYLE_ENDPOINT=false

FAQ

Is this package really necessary?

No, you can use the s3 driver with Cloudflare R2, but this package makes it easier to use. Just be sure to set 'retain_visibility' => false, in your standard s3 configuration to prevent incompatibility issues.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
1.0.2 ^8.2 ^10.0||^11.0||^12.0||^13.0 MIT
1.0.1 ^8.2 ^10.0||^11.0||^12.0 MIT
1.0.0 ^8.2 ^10.0||^11.0 MIT