flarum/framework · error · RuntimeException
intervention/image: $driver is not valid
Error message
intervention/image: $driver is not valid
What it means
The ImageServiceProvider resolves an intervention/image v3 driver from configuration and validates it against the known driver map ('gd', 'imagick'). If the configured driver name is not in that map (after the imagick-availability fallback), a RuntimeException is thrown during container registration.
Solutions
- Set the driver to 'gd' or 'imagick' in the config (config/image.php or extender)
- Check extension_loaded('imagick') and install php-imagick if imagick is desired
- Clear config cache so the corrected value is used
Example fix
// before
'driver' => 'imagemagick',
// after
'driver' => extension_loaded('imagick') ? 'imagick' : 'gd', Defensive patterns
Strategy: validation
Validate before calling
$driver = $config->get('image.driver', 'gd');
if (! in_array($driver, ['gd', 'imagick'])) {
throw new InvalidArgumentException("image.driver must be 'gd' or 'imagick', got '$driver'");
}
if ($driver === 'imagick' && ! extension_loaded('imagick')) { $driver = 'gd'; } Try / catch
try {
$manager = $app->make(ImageManager::class);
} catch (RuntimeException $e) {
// fall back to gd explicitly
$app->instance('image.driver', 'gd');
$manager = $app->make(ImageManager::class);
} Prevention
- Only set image.driver to 'gd' or 'imagick' (intervention/image v3 values)
- Run php -m to confirm imagick is installed before selecting it
- Clear config cache after changing the driver config
When it happens
Trigger: Config value image.driver set to something other than 'gd' or 'imagick' (e.g. leftover intervention/image v2 string like 'Gd' with wrong casing or a custom name); typo in config.
Common situations: Upgrading from intervention/image v2 to v3 where driver configuration shape changed; copying config from tutorials using unsupported values like 'imagemagick'.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- Paths are not possible in websocket connections.
- You cannot disable the default language pack!
- validation. (translated message for )
- Configuration file does not exist.
- Please specify a database driver.
AI-assisted analysis of flarum/framework@4b939f6853 (2026-09-15).
Data as JSON: /api/errors/f1133006fbf8d6b3.
Report an issue: GitHub.
Appendix: source
Thrown at framework/core/src/Image/ImageServiceProvider.php:45
'imagick' => Drivers\Imagick\Driver::class
];
});
$this->container->singleton('image', function (Container $container): ImageManager {
$interventionDrivers = $container->make('image.drivers');
$configDriver = $container->make(Config::class)->offsetGet('intervention.driver');
// Default to 'gd' if not present in the config
$driver = $configDriver ?? 'gd';
// Check that the imagick library is actually available, else default back to gd.
if ($driver === 'imagick' && ! extension_loaded('imagick')) {
$driver = 'gd';
}
if (! Arr::has($interventionDrivers, $driver)) {
throw new RuntimeException("intervention/image: $driver is not valid");
}
return new ImageManager($interventionDrivers[$driver]);
});
$this->container->alias('image', ImageManager::class);
}
}
View on GitHub (pinned to 4b939f6853)