Fresh code drop

Migrate storage with a read-through disk

PHP

Laravel 13 API example based on official Laravel documentation. Source: https://laravel.com/docs/13.x/filesystem#scoped-read-only-and-read-through-filesystems

PHP
CodeSnap // free canvas

Migrate storage with a read-through disk

<?php

// config/filesystems.php
'assets' => [
    'driver' => 'read-through',
    'primary' => 'r2',
    'fallback' => 'legacy-s3',
    'throw_on_promotion_failure' => false,
],

// A fallback read is promoted to the primary disk.
$logo = Storage::disk('assets')->get('logos/app.svg');

// Further reading: https://laravel.com/docs/13.x/filesystem#scoped-read-only-and-read-through-filesystems

Turn your code into a post.Five templates are free—no account needed.

Remix this snap