Verifactu-PHP is an open-source PHP library that lets you build a Sistema Informático de Facturación (SIF) compliant with Spain’s VERI*FACTU regulation. It handles the full lifecycle of a billing record: constructing the data model, computing the SHA-256 chain hash, validating every field against the official schema, serialising to the AEAT SOAP envelope, and dispatching it over a mutually-authenticated TLS connection — all from a single, well-typed PHP 8.2+ API.Documentation 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.
What is VERI*FACTU?
VERI*FACTU is the Spanish billing-record regulation introduced by Royal Decree 1007/2023 (RD 1007/2023). It requires certain businesses to record a summary of every invoice they issue inside a certified billing system (SIF), and to either transmit each record to the Agencia Estatal de Administración Tributaria (AEAT) in real time or keep the records with an electronic signature and an audit-trail log available on demand. The regulation applies to all natural and legal persons subject to:- IRPF (personal income tax) for economic activities
- Impuesto de Sociedades (corporate income tax)
- IRNR (non-resident income tax) with a permanent establishment in Spain
- Businesses already enrolled in the Suministro Inmediato de Información (SII), which transmit invoice data to the AEAT daily, are exempt.
- Operations that do not legally require an invoice (or that hold special authorised billing arrangements) are also excluded.
| Mode | Requirement |
|---|---|
| VERI*FACTU | Every registration record must be sent to the AEAT immediately after the invoice is issued. |
| Non-VERI*FACTU | Records are kept locally with an electronic signature and an events log; the AEAT may request them via a formal requerimiento. |
What this library provides
Verifactu-PHP covers every technical step required to build a VERI*FACTU-compliant SIF:RegistrationRecordandCancellationRecordmodels — fully typed PHP objects for invoice registration (alta) and cancellation (anulación) records, with SHA-256 hash chaining built in viacalculateHash().- Symfony Validator integration — call
validate()on any model to get a structured list of constraint violations before you ever touch the network. - AEAT SOAP submission with mTLS —
AeatClientwraps Guzzle to send records to the correct pre-production or production SOAP endpoint, using your FNMT certificate for mutual TLS authentication. - XML import and export — every model can be serialised to the AEAT XML schema and deserialised back, making it straightforward to store and replay records.
- QR URL generation — generate the VERI*FACTU QR verification URL that must appear on printed invoices.
- Async-first API —
AeatClient::send()returns a GuzzlePromiseInterface, so you can batch multiple submissions without blocking your application.
Who should use it
Verifactu-PHP is aimed at PHP developers who need to integrate VERI*FACTU compliance into a billing application, ERP system, or any other SIF. It provides the low-level building blocks — record construction, hashing, validation, and transmission — so you can focus on your own business logic rather than the AEAT XML specification.Quickstart
Send your first record to the AEAT pre-production endpoint in under 5 minutes.
Installation
System requirements, Composer setup, and dependency overview.
VERI*FACTU overview
Deep dive into the regulation, record types, and hash chaining.
Registration records
Build and submit RegistrationRecord objects for every invoice type.
Requirements
Before installing the library, make sure your environment meets the following minimum requirements:- PHP 8.2 or higher — the library uses readonly properties, intersection types, and other modern PHP features.
- libxml extension — required for XML serialisation; it is bundled with most PHP distributions and enabled by default.
- Composer — the library is distributed via Packagist and installed through Composer.
License
Verifactu-PHP is released under the MIT License. You may use it in any project, including commercial ones, as long as you retain the copyright notice and attribute the original authorship.This library does not include a declaración responsable (responsible declaration) because it is a development tool, not a certified SIF in itself. As the developer integrating Verifactu-PHP into your product, you are responsible for auditing the source code and ensuring your SIF complies with RD 1007/2023 and any subsequent AEAT technical specifications. See Article 13 of RD 1007/2023 for the full list of SIF obligations.