Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

simioluwatomi's avatar

How to use local filesystem for development but S3 for production

Please, how can I use my local filesystem for development and S3 for production? My application is going to be handling large file uploads (between 100 - 150MB) but it is currently configured to use s3 as its default even in development.

I would need to upload a lot of files for testing purposes so I have decided it will be better to have different filesystem settings based on the app environment. How do I go about this?

My config/filesystem.php currently looks like this

    'default' => 's3',    

    'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

        'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
        ],

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_KEY'),
            'secret' => env('AWS_SECRET'),
            'region' => env('AWS_REGION'),
            'bucket' => env('AWS_BUCKET'),
        ],

    ],
    
0 likes
3 replies
Nash's avatar
Nash
Best Answer
Level 20

Just set the default disk via an environment variable: 'default' => env('FILESYSTEM_DRIVER'),

In your .env file, set FILESYSTEM_DRIVER to local or s3 depending on your current environment: FILESYSTEM_DRIVER=local

1 like
martinbean's avatar

@simioluwatomi If you look further up in the config/filesystems.php file, there’s a default key that points to an environment variable:

'default' => env('FILESYSTEM_DRIVER', 'local')

So you can set FILESYSTEM_DRIVER=local in your .env file when working locally, and set FILESYSTEM_DRIVER=s3 on your production server and it will use S3.

1 like
simioluwatomi's avatar

@martinbean This is a L5.4 project migrated to L5.5. The corresponding line is

'default' => 's3', 

The reason why I'm giving the best answer to @Nash is because he answered first.

Thanks!!!!!

Please or to participate in this conversation.