Skip to content

Commit 85ef845

Browse files
sl0wiktaylorotwell
andauthored
[10.x] Configurable storage path via environment variable (#48115)
* [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 <[email protected]>
1 parent 4899c53 commit 85ef845

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Illuminate/Foundation/Application.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,10 @@ public function usePublicPath($path)
529529
*/
530530
public function storagePath($path = '')
531531
{
532+
if (isset($_ENV['LARAVEL_STORAGE_PATH'])) {
533+
return $this->joinPaths($this->storagePath ?: $_ENV['LARAVEL_STORAGE_PATH'], $path);
534+
}
535+
532536
return $this->joinPaths($this->storagePath ?: $this->basePath('storage'), $path);
533537
}
534538

0 commit comments

Comments
 (0)