Skip to content

Commit

Permalink
[10.x] Configurable storage path via environment variable (#48115)
Browse files Browse the repository at this point in the history
* [10.x] Configurable storage path via environment variable

In the current implementation, the storage directory is statically set to `storage`. Given that this directory requires write permissions, it poses challenges in serverless environments and other scenarios where the filesystem might be read-only.

To enhance Laravel's adaptability to diverse hosting environments, this pull request introduces the capability to override the default storage directory using the `STORAGE_PATH` environment variable.

* formatting

* formatting

---------

Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
sl0wik and taylorotwell committed Aug 21, 2023
1 parent 4899c53 commit 85ef845
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Illuminate/Foundation/Application.php
Expand Up @@ -529,6 +529,10 @@ public function usePublicPath($path)
*/
public function storagePath($path = '')
{
if (isset($_ENV['LARAVEL_STORAGE_PATH'])) {
return $this->joinPaths($this->storagePath ?: $_ENV['LARAVEL_STORAGE_PATH'], $path);
}

return $this->joinPaths($this->storagePath ?: $this->basePath('storage'), $path);
}

Expand Down

0 comments on commit 85ef845

Please sign in to comment.