TaffoVelikoff / imagekit-adapter

A Laravel/Flysystem adapter for ImageKit.
https://packagist.org/packages/taffovelikoff/imagekit-adapter
MIT License
11 stars 2 forks source link

Laravel 9 / PHP 8.1 support #6

Open khalyomede opened 2 years ago

khalyomede commented 2 years ago

I tried to use the package with Laravel 9.15.1 / PHP 8.1.5, and it thrown this exception when I ran:

Storage::disk("imagekit")->url("img/logo-96-96.png")
Class "League\Flysystem\Adapter\AbstractAdapter" not found

I guess this package has been tested with Flysystem v1, but Laravel 9 uses v3

TaffoVelikoff commented 2 years ago

Yes, I haven't been able to test and modify for Laravel 9. I hope I have the time to do so soon!

TaffoVelikoff commented 2 years ago

Just released an update for PHP8. The package is no longer Laravel only, it can be used in any PHP project. I did add a "Usage in Laravel" guide in the README.

ameen06 commented 1 year ago

Hlo TaffoVelikoff, This issue still exists. It works fine in local, but in production it is showing this error. Error: Class "TaffoVelikoff\ImageKitAdapter\ImageKitAdapter" not found

ameen06 commented 1 year ago

I fixed the issue. Instead of boot method, we should be registering the adapter in the register method. this is for Laravel.

public function register(): void { $this->app->bind(ImagekitAdapter::class, function ($app, $config) { return new ImagekitAdapter( new ImageKit( config('filesystems.disks.imagekit.public_key'), config('filesystems.disks.imagekit.private_key'), config('filesystems.disks.imagekit.endpoint_url') ) ); }); Storage::extend('imagekit', function ($app, $config) { $adapter = $app->make(ImagekitAdapter::class); return new FilesystemAdapter( new Filesystem($adapter, $config), $adapter, $config ); }); }