Intervention/image · error · Intervention\Image\Exceptions\InvalidArgumentException
Argument $driver must be existing class name
Error message
Argument $driver must be existing class name
What it means
Error "Argument $driver must be existing class name" thrown in Intervention/image.
Source
Thrown at src/Traits/CanResolveDriver.php:20
declare(strict_types=1);
namespace Intervention\Image\Traits;
use Intervention\Image\Exceptions\InvalidArgumentException;
use Intervention\Image\Interfaces\DriverInterface;
trait CanResolveDriver
{
/**
* Resolve given string or driver to a driver instance with given options.
*
* @throws InvalidArgumentException
*/
protected static function resolveDriver(string|DriverInterface $driver, mixed ...$options): DriverInterface
{
if (is_string($driver) && !class_exists($driver)) {
throw new InvalidArgumentException(
'Argument $driver must be existing class name',
);
}
if (is_string($driver) && !is_subclass_of($driver, DriverInterface::class)) {
throw new InvalidArgumentException(
'Argument $driver must be an implementation of ' . DriverInterface::class,
);
}
$driver = is_string($driver) ? new $driver() : $driver;
$driver->config()->setOptions(...$options);
return $driver;
}
}
View on GitHub (pinned to 5598b9e397)
Solutions
- Pass a fully-qualified existing class name as the driver, e.g. Intervention\Image\Drivers\Gd\Driver::class
- Check for typos in the driver class string and that the package providing it is installed
- Use class_exists() to validate dynamic driver names before resolving
When it happens
Trigger: Thrown at src/Traits/CanResolveDriver.php:20 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/062b238bd2a47a41.
Report an issue: GitHub.