Intervention/image · error · Intervention\Image\Exceptions\NotSupportedException
No modifier for {$drawable::class} found
Error message
No modifier for {$drawable::class} found What it means
Image::draw() dispatches to a modifier via a match on the concrete drawable class: Rectangle, Circle/Ellipse, Bezier, Line and Polygon are supported. Any other DrawableInterface implementation — including subclasses of the built-in ones, since the match is on ::class, not instanceof — falls to the default arm and throws NotSupportedException. Custom drawable shapes are not extensible through this entry point.
Source
Thrown at src/Image.php:1142
/**
* {@inheritdoc}
*
* @see ImageInterface::draw()
*
* @throws InvalidArgumentException
* @throws NotSupportedException
* @throws ModifierException
* @throws ColorDecoderException
*/
public function draw(DrawableInterface $drawable): ImageInterface
{
return $this->modify(match ($drawable::class) {
Rectangle::class => new DrawRectangleModifier($drawable),
Circle::class, Ellipse::class => new DrawEllipseModifier($drawable),
Bezier::class => new DrawBezierModifier($drawable),
Line::class => new DrawLineModifier($drawable),
Polygon::class => new DrawPolygonModifier($drawable),
default => throw new NotSupportedException('No modifier for ' . $drawable::class . ' found'),
});
}
/**
* {@inheritdoc}
*
* @see ImageInterface::encode()
*
* @throws EncoderException
*/
public function encode(?EncoderInterface $encoder = null): EncodedImageInterface
{
return $this->driver()->specializeEncoder(
$encoder ?: new AutoEncoder(),
)->encode($this);
}
/**View on GitHub (pinned to 5598b9e397)
Solutions
- Use the built-in drawable classes (Rectangle, Ellipse, Circle, Bezier, Line, Polygon) and configure them via their setters instead of subclassing
- If you need custom rendering, write a custom Modifier and invoke it via $image->modify(new MyModifier()) directly
- Pass the exact built-in class, not a subclass, to draw()
- Pin/upgrade the intervention/image version so the drawable classes you reference exist in the match list
Example fix
// before
$image->draw(new class extends Rectangle { /* ... */ }); // NotSupportedException
// after
$image->draw((new Rectangle(100, 100))->setBackgroundColor('f00'));
// or custom rendering:
$image->modify(new DrawCustomShapeModifier($customData)); Defensive patterns
Strategy: type-guard
Validate before calling
$supported = [Rectangle::class, Ellipse::class, Circle::class, Bezier::class, Line::class, Polygon::class];
if (!in_array($drawable::class, $supported, true)) {
throw new InvalidArgumentException('Unsupported drawable: ' . $drawable::class);
}
$image->draw($drawable); Type guard
function isBuiltInDrawable(object $drawable): bool
{
return in_array($drawable::class, [
\Intervention\Image\Geometry\Rectangle::class,
\Intervention\Image\Geometry\Ellipse::class,
\Intervention\Image\Geometry\Circle::class,
\Intervention\Image\Geometry\Bezier::class,
\Intervention\Image\Geometry\Line::class,
\Intervention\Image\Geometry\Polygon::class,
], true); // exact class match — subclasses are NOT supported
} Try / catch
try {
$image->draw($shape);
} catch (NotSupportedException $e) {
// programming error: switch to a built-in shape or a custom Modifier
} Prevention
- Do not subclass drawables — the dispatch matches the exact class name
- For custom rendering, implement a Modifier and call $image->modify()
- Cover the drawable list with a unit test after upgrading intervention/image
When it happens
Trigger: $image->draw(new MyCustomShape()) where MyCustomShape implements DrawableInterface but is none of the five known classes; also new class RectangleSubclass() (match on $drawable::class does not match the parent case).
Common situations: Upgrading custom code from older Intervention versions where shapes were extensible, or writing a custom drawable expecting polymorphic dispatch. Version changes that introduce new drawable classes not present in the installed release can also surface this.
Related errors
- Failed to invert color
- Percentage value must be between -100 and 100
- Color channel {class} value must be in range {min} to {max}
- Unable to parse CMYK color from input "{input}"
- Class '{objectShortname}' is not supported by {id} driver
AI-assisted analysis of Intervention/image@5598b9e397 (2026-08-23).
Data as JSON: /api/errors/6e640f2a8d94b1e6.
Report an issue: GitHub.