I want to configure the storage path in a Laravel 5.1 using the .env
file. My bootstrap/app.php
looks like this:
<?php
$app = new \Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
);
$app->useStoragePath(getenv('STORAGE_PATH'));
and the relevant line in .env file is:
STORAGE_PATH=/var/www/storage
This doesn't work. I figured out the Dotenv library is initialised after the bootstrap is processed so the .env
variables are not available in bootstrap.php
.
Is there a different place where I can set the storage path and the .env
variables are available?
In config/filesystems.php
you can set your storage path. Try setting your storage path there and see if it works. Note that the example below is my suggestion as to how your config/filesystems.php
should look. Don't mind the s3 setup. That's a 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',
],
],
];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With