PHPOffice/PHPWord · error · PhpOffice\PhpWord\Exception\Exception
Writer element class
Error message
Writer element class {$writerClass} not found. What it means
Class-resolution guard: the EPub3 writer maps a PhpWord element class to a same-named writer element under Writer\EPub3\Element; class_exists() failed, so that element type has no EPub3 writer implementation. Indicates an unsupported element or a missing/wrongly named writer class.
Solutions
- Create or register a matching writer element class in PhpOffice\PhpWord\Writer\EPub3\Element for the unsupported element.
- Catch the exception and skip or render the element with a default writer element instead.
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at src/PhpWord/Writer/EPub3/Element/AbstractElement.php:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of PHPOffice/PHPWord@aef95c0415 (2026-09-14).
Data as JSON: /api/errors/2277da116ac59535.
Report an issue: GitHub.
Appendix: source
Thrown at src/PhpWord/Writer/EPub3/Element/AbstractElement.php:40
/**
* Abstract element writer.
*
* @since 0.11.0
*/
abstract class AbstractElement extends Word2007AbstractElement
{
/**
* Get class name of writer element based on read element.
*
* @param \PhpOffice\PhpWord\Element\AbstractElement $element
*/
public static function getElementClass($element): string
{
$elementClass = str_replace('PhpOffice\\PhpWord\\Element\\', '', get_class($element));
$writerClass = 'PhpOffice\\PhpWord\\Writer\\EPub3\\Element\\' . $elementClass;
if (!class_exists($writerClass)) {
throw new \PhpOffice\PhpWord\Exception\Exception("Writer element class {$writerClass} not found.");
}
return $writerClass;
}
}
View on GitHub (pinned to aef95c0415)