sn n
sn n

Reputation: 399

Storage path outside root directory

I am trying to store the file cache data outside my Laravel project. I have added the below snippet in my cache config file.

      'file' => [
            'driver' => 'file',
            'path' => storage_path('Users/path/to'),
        ],

However, the folder hierarchy passed within storage_path is getting appended and cached data is stored within root directory. Any suggestion on how do I provide a path so that I can store it outside the laravel project.

Upvotes: 0

Views: 2087

Answers (1)

jackwebs
jackwebs

Reputation: 51

The storage_path function prepends the path given with the path to your app's storage directory, so will always return a directory inside the storage path. If you want to specify a path outside your app, just remove the function:

'file' => [
    'driver' => 'file',
    'path' => 'Users/path/to',
],

Depending on how you have your webserver configured, you may run into problems with permission errors. I would consider using a symbolic link inside the storage path, rather than directly linking to a path outside.

Upvotes: 1

Related Questions