I am having a problem with intervention image and Laravel 11. I am upgrading a program which is fine with Laravel 10.
I installed with
composer require intervention/image-laravel
and then ran
php artisan vendor:publish --provider="Intervention\Image\Laravel\ServiceProvider"
I have also installed Unisharp's filemanager and I notice that the composer.json file has these two entries
"intervention/image": "^3.11",
"intervention/image-laravel": "^1.5",
I have a function to resize which includes
if (!file_exists($image2)) {
//200 wide
if (file_exists($image)) {
$destinationPath = $path2;
$imgsave2 = $destinationPath . '/' . $img;
$img2 = Image::read($image);
$img2
->resize(200, null, function ($constraint) {
$constraint->aspectRatio();
})
->save($imgsave2);
}
}
(This simply takes in the image as image2 and the destination path and places it in a subdirectory based on the image size, hence the destination path). This function has
use Intervention\Image\Laravel\Facades\Image;
at the top
When I first tried to use this I had am image that it could not find Image so I setup a facade as
class AliasServiceProvider extends ServiceProvider
{
/**
* Register services.
*/
public function register(): void
{
$loader = AliasLoader::getInstance();
$loader->alias('Image', Intervention\Image\Laravel\Facades\Image::class);
}
/**
* Bootstrap services.
*/
public function boot(): void
{
//
}
Also in the providers in the bootstrap directory I have:
App\Providers\AliasServiceProvider::class,
Now when I try to use it I am getting an error
Unable to resolve driver. Argument must be either an instance of Intervention\Image\Interfaces\DriverInterface::class or a qualified namespaced name of the driver class.
I am going around and around with this any help would be very greatly appreciated.