Storage path using .env in Laravel 5.1

I want to configure the storage path in Laravel 5.1 using an .env file. My bootstrap/app.php looks like this:

 <?php $app = new \Illuminate\Foundation\Application( realpath(__DIR__.'/../') ); $app->useStoragePath(getenv('STORAGE_PATH')); 

and the corresponding line in the .env file:

 STORAGE_PATH=/var/www/storage 

This does not work. I realized that the Dotenv library is initialized after bootstrap processing, so the .env variables .env not available in bootstrap.php .

Is there any other place where I can set the storage path and the .env variables are available?

+5
source share
1 answer

In config/filesystems.php you can set the repository path. Try setting the path to the repository and see if it works. Please note that the example below is my suggestion as to what your config/filesystems.php should look like. Do not mind setting s3. This is part of my project.

Remember to remove $app->useStoragePath(getenv('STORAGE_PATH')); from app.php

 return [ 'default' => 's3', 'cloud' => 's3', 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => env('STORAGE_PATH'), ], 's3' => [ 'driver' => 's3', 'key' => env('AWS_KEY'), 'secret' => env('AWS_SECRET'), 'region' => env('AWS_REGION'), 'bucket' => env('AWS_BUCKET'), ], 'rackspace' => [ 'driver' => 'rackspace', 'username' => 'your-username', 'key' => 'your-key', 'container' => 'your-container', 'endpoint' => 'https://identity.api.rackspacecloud.com/v2.0/', 'region' => 'IAD', ], ], ]; 
+3
source

All Articles