By John Koster
The storage_path
will return the path to the storage
directory. It can also be used to construct paths relative to the storage
directory if a $path
is supplied.
#Signature
The signature of the storage_path
function is:
1function storage_path(
2 $path = ''
3);
#Example Use
The following examples will assume that the Laravel application is installed in the
/home/vagrant/Code/Laravel/
directory. The resulting path will appear above the function calls as a comment.
1// /home/vagrant/Code/Laravel/storage
2storage_path();
3
4// /home/vagrant/Code/Laravel/storage/logs
5storage_path('logs');
6
7// /home/vagrant/Code/Laravel/storage/framework/sessions
8storage_path('framework/sessions');
The storage_path
does not automatically add the trailing slash /
character to the final string. storage_path
's return value can be passed into the str_finish
function to achieve the same affect:
1// /home/vagrant/Code/Laravel/storage/logs/
2str_finish(storage_path('logs'), '/');
∎