Verifactu-PHP supports full round-trip XML serialization for bothDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/josemmo/Verifactu-PHP/llms.txt
Use this file to discover all available pages before exploring further.
RegistrationRecord and CancellationRecord. This is useful for storing records in a database or filesystem, producing AEAT-format XML for auditing purposes, or integrating with external systems that consume the VERI*FACTU XSD format.
XML serialization depends on the
josemmo/uxml library for XML manipulation. It is installed automatically as a Composer dependency — no additional setup is required.Exporting records to XML
UseUXML::newInstance() to create a container element with the correct sum1 namespace binding, then call $record->export() passing the container and your ComputerSystem instance. Retrieve the resulting element with ->get() and call ->asXML() to obtain the XML string.
CancellationRecord, the element name changes to sum1:RegistroAnulacion:
Importing records from XML
UseUXML::fromString() to parse an XML document, then call the static Record::fromXml() method. It automatically detects the record type based on the root element name (sum1:RegistroAlta → RegistrationRecord, sum1:RegistroAnulacion → CancellationRecord) and returns the appropriate object.
XML namespaces
All VERI*FACTU record elements live in theSuministroInformacion XML namespace. The namespace URI is available as a public constant on the Record base class:
sum1 prefix:
sum1, or omitting the namespace binding, will produce XML that Record::fromXml() cannot parse — the import method enforces the sum1 prefix on the root element.
Error handling
Record::fromXml() throws an ImportException if the XML is structurally invalid, missing required elements, or contains values that cannot be mapped to the expected enum types. Always wrap imports in a try / catch block:
ImportException:
| Cause | Example |
|---|---|
| Missing required element | <sum1:IDFactura /> absent from the document |
| Unknown enum value | <sum1:TipoFactura>XX</sum1:TipoFactura> (not a valid InvoiceType) |
| Malformed date | <sum1:FechaExpedicionFactura>2026/03/15</sum1:FechaExpedicionFactura> (wrong format) |
| Wrong namespace prefix | Root element is RegistroAlta instead of sum1:RegistroAlta |