Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Build an on-demand filesystem disk #37720

Merged
merged 1 commit into from
Jun 18, 2021

Conversation

browner12
Copy link
Contributor

Occasionally I will need to access a file that does not currently reside within the root of a configured filesystem disk. I don't really want to create a full "disk" for them, because often this is a very one-off, or even temporary need. Sometimes it won't even get committed, but I just need it for a quick local dev use.

This PR allows us to make "on-demand" disks using the build() method.

There are 2 ways to build this on-demand disk. If you pass a string to the build() method, it will build a disk with a local driver, and the root pointed to the passed path.

Storage::build(storage_path('logs'));

You can also pass an array to have full control of the configuration:

Storage::build([
    'driver'     => 'local',
    'root'       => 'my-custom-path',
    'url'        => 'my-custom-url',
    'visibility' => 'public',
]);

the `build` method allows the user to create an on-demand filesystem disk.

a string passed to the method will be treated as the "root" of a local driver (99% use case).

passing an array allows full customization of the disk config.
@taylorotwell
Copy link
Member

@browner12 did you have a big reason for storing the disk in the ondemand key? Should we just return it and not store it?

@taylorotwell taylorotwell merged commit 3ec57b2 into laravel:8.x Jun 18, 2021
@taylorotwell
Copy link
Member

Removed the part that cached it on the disks array - if that was super important let me know.

@browner12
Copy link
Contributor Author

AFAIK not important. Only did it because the other ones did it.

@browner12 browner12 deleted the on-demand-filesystem branch June 18, 2021 15:12
browner12 added a commit to browner12/framework that referenced this pull request Jun 18, 2021
taylorotwell pushed a commit that referenced this pull request Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants