-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[9.x] Flysystem v2 #33612
[9.x] Flysystem v2 #33612
Conversation
} | ||
|
||
return $driver; | ||
return $this->customCreators[$config['driver']]($this->app, $config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes require custom creators to return an instance of Illuminate\Contracts\Filesystem\Filesystem
rather than an instance of League\Flysystem\FilesystemInterface
. The reason for that is that creating a FilesystemAdapter
instance is now much more complex than what the previous adapt
method did (see a bit further below).
d6a20ae
to
81851e5
Compare
5b56283
to
7e4d88c
Compare
Fixed. |
8f679ed
to
ee36968
Compare
ee36968
to
54ac2c7
Compare
54ac2c7
to
c544ffc
Compare
c544ffc
to
c6a2f49
Compare
c6a2f49
to
2e8c2fb
Compare
I need quite a bit more info on:
I have to document more info than this - what should I include specifically? Can you give me a before and after example of something that might affect user land code?
Does this mean all custom disk implementations are now broken? If so, can you provide a before and after example of how to fix a hypothetical custom disk so that I can properly document the process in the upgrade guide. Otherwise, users will have nothing to go on if all I mention is the sentence above. In other words, can you give me an example of how to define a custom disk in Laravel 8.x (there is one in docs) and then an example of how to do it in Laravel 9.x? |
No real userland code is affected here, only when people are instantiating their own filesystem adapters or packages adding new drivers. use Illuminate\Filesystem\FilesystemAdapter;
$flysystem = new Flysystem($adapter, $config);
// Before...
$filesystem = new FilesystemAdapter($flysystem);
// After...
return new FilesystemAdapter($flysystem, $adapter, $config);
Yes, custom disks will need to update their implementation. // Before...
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;
Storage::extend('dropbox', function ($app, $config) {
$client = new DropboxClient(
$config['authorization_token']
);
return new Filesystem(new DropboxAdapter($client));
});
// After...
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use League\Flysystem\Filesystem as Flysystem;
use Spatie\Dropbox\Client as DropboxClient;
use Spatie\FlysystemDropbox\DropboxAdapter;
Storage::extend('dropbox', function ($app, $config) {
$client = new DropboxClient(
$config['authorization_token']
);
$adapter = new DropboxAdapter($client);
$flysystem = new Flysystem($adapter, $config);
return new FilesystemAdapter($flysystem, $adapter, $config);
}); |
Initial attempt at migrating to (currently unreleased) Flysystem v2. Might be a little too soon for Laravel 8. In draft until Flysystem v2 has been released.
Breaking Changes
put
,write
,writeStream
, etc) now overwrites by default. Checking for existing files needs to be done in user land from now on.writeStream
no longer throws aFileExistsException
. Since this exception is nowhere used anymore in the framework, it's been removed.get
&readStream
no longer throw aFileNotFoundException
exception when a file exists. This is because the underlying Flysystem integration no longer distinguishes this specific failure from any other read failure. Both methods will returnnull
when they cannot read a file.delete
returnstrue
now even if the file wasn't found.Illuminate\Contracts\Filesystem\Filesystem
rather thanLeague\Flysystem\FilesystemInterface
like before. See [9.x] Flysystem v2 #33612 (comment)Illuminate\Filesystem\FilesystemAdapter
's constructor now requires an extra$adapter
argument and an optional$options
argument.