{"record":{"id":"062b238bd2a47a41","repo":"Intervention/image","slug":"argument-driver-must-be-existing-class-name","errorCode":null,"errorMessage":"Argument $driver must be existing class name","messagePattern":"Argument \\$driver must be existing class name","errorType":"exception","errorClass":"Intervention\\Image\\Exceptions\\InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Traits/CanResolveDriver.php","lineNumber":20,"sourceCode":"\ndeclare(strict_types=1);\n\nnamespace Intervention\\Image\\Traits;\n\nuse Intervention\\Image\\Exceptions\\InvalidArgumentException;\nuse Intervention\\Image\\Interfaces\\DriverInterface;\n\ntrait CanResolveDriver\n{\n    /**\n     * Resolve given string or driver to a driver instance with given options.\n     *\n     * @throws InvalidArgumentException\n     */\n    protected static function resolveDriver(string|DriverInterface $driver, mixed ...$options): DriverInterface\n    {\n        if (is_string($driver) && !class_exists($driver)) {\n            throw new InvalidArgumentException(\n                'Argument $driver must be existing class name',\n            );\n        }\n\n        if (is_string($driver) && !is_subclass_of($driver, DriverInterface::class)) {\n            throw new InvalidArgumentException(\n                'Argument $driver must be an implementation of ' . DriverInterface::class,\n            );\n        }\n\n        $driver = is_string($driver) ? new $driver() : $driver;\n        $driver->config()->setOptions(...$options);\n\n        return $driver;\n    }\n}\n","sourceCodeStart":2,"sourceCodeEnd":37,"githubUrl":"https://github.com/Intervention/image/blob/5598b9e39751c34afc5cdee84abef77f92c26f68/src/Traits/CanResolveDriver.php#L2-L37","documentation":"Error \"Argument $driver must be existing class name\" thrown in Intervention/image.","triggerScenarios":"Thrown at src/Traits/CanResolveDriver.php:20 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5598b9e39751c34afc5cdee84abef77f92c26f68","analyzedAt":"2026-08-23T02:17:31.068Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}