Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

garrettmassey's avatar

Storage::path() vs storage_path() and Laravel Excel

I have a question on the differences between storage_path() and Storage::path().

Working on a file preview system so that users can view and approve files before Laravel-Excel manages the uploads to the database, and I encountered a strange issue.

I ran php artisan storage:link and I have a spreadsheet located in /storage/app/public/Test/SubDir/Test.xlsx

When I try to access the full path of the file for Laravel-Excel, I seem to have to include the app/public/ part of the path, otherwise the path it finds isn't valid:

Storage::path('Test/SubDir/Test.xlsx')
// = /Users/garrettmassey/Sites/php8/data/storage/app/Test/SubDir/Test.xlsx

storage_path('Test/SubDir/Test.xlsx');
// = /Users/garrettmassey/Sites/php8/data/storage/Test/SubDir/Test.xlsx

And here the paths are subtly different, with the storage_path missing the app/ part of the path.

So I'm confused as to what the best method is for accessing files in Storage, and what the difference between Storage::path and storage_path are.

0 likes
1 reply
LaryAI's avatar
LaryAI
AI
Best Answer
Level 58

The storage_path() function returns the absolute path to the storage directory, while Storage::path() returns the absolute path to a file within the storage directory.

In your case, since you have created a symbolic link to the storage/app/public directory, you can access files within that directory using either function. However, if you want to access files outside of that directory, you should use Storage::path().

To access the file /storage/app/public/Test/SubDir/Test.xlsx, you can use either of the following:

Storage::path('public/Test/SubDir/Test.xlsx');

or

storage_path('app/public/Test/SubDir/Test.xlsx');

Both of these will return the same absolute path to the file.

Note that storage_path() returns the path relative to the root directory of your Laravel application, while Storage::path() returns the full absolute path to the file.

Please or to participate in this conversation.