danhunsaker / laravel-flysystem-service

Registers recognized Flysystem adapters with Laravel automatically.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Target class [files] does not exist

JamesPJ opened this issue · comments

After replacing Illuminate\Filesystem\FilesystemServiceProvider::class in providers list. I'm getting below error.

In Container.php line 811:
                                        
  Target class [files] does not exist. 

It used to work on Laravel 5.8 version. But, after upgrading to Laravel 7.x it is throwing the error.

I've done little research on the error, and as per this issue laravel/framework#35120 the service provider is not really registering the file system.

By going through the core file system https://github.com/laravel/framework/blob/7.x/src/Illuminate/Filesystem/FilesystemServiceProvider.php I found the below statement is missing in FlysystemOtherServiceProvider.

$this->app->singleton('files', function () {
            return new Filesystem;
});

Interesting. I wonder what they changed that made it stop working. I'll see about adding that.

Based on the code I'm looking at, this should still work as expected... The FlysystemServiceProvider extends Illuminate\Filesystem\FilesystemServiceProvider, making it register all its own services except the replacement FlysystemManager...

Yes, it should have worked. I don't know some reason, it looked like the application was not at all recognising the service provider. If I replace with default provider, it works.

Not sure it is only happening in my application or not. I'll check it with a bare L8 application when I get time.

For time being I've extended default file file system in my application. As I'm only using the http additional driver.

I'm having the same problem - I'm using my own customised FilesystemServiceProvider, which extends from the Laravel one, but it just doesn't seem to recognise it now following upgrade from 5.8 to 6.

Oddly, if I just leave the original provider in place in config/app.php, then also include my one below, it works, and still does what I want it to do from my own provider:

Illuminate\Filesystem\FilesystemServiceProvider::class,
Library\Extensions\Filesystem\FilesystemServiceProvider::class,