Introduction to PHP FacturaE
PHP FacturaE is a modern, type-safe library for generating, validating, and signing electronic invoices in the FacturaE format — the official standard for e-invoicing in Spain.What is FacturaE?
FacturaE is the XML-based electronic invoice format required by Spanish public administration (AAPP) and widely adopted in the private sector. It’s managed by the Spanish Tax Agency (AEAT) and ensures fiscal compliance and interoperability.Why PHP FacturaE?
PHP FacturaE provides a fluent, type-safe API that makes creating compliant invoices intuitive and error-free:Key Features
Fluent API with Enums
No associative arrays or loose constants — everything is strongly typed with PHP 8.2+ enums and readonly properties
XAdES-EPES Digital Signatures
Built-in support for PKCS#12 (.pfx) and PEM certificates with optional TSA timestamping
XSD Validated
Automatically validates against official FacturaE 3.2, 3.2.1, and 3.2.2 schemas
Zero Dependencies
Only requires standard PHP extensions:
ext-openssl, ext-dom — no external packagesComprehensive Tax Support
- 29 tax types including IVA, IRPF, IGIC, recargo de equivalencia, and special taxes
- 19 payment methods from transfer to card to direct debit
- 36 units of measure from pieces to kWh to hours
- 22 correction reasons for corrective invoices
Performance
- ~0.2 ms per simple invoice
- ~22 ms for 100 invoices
- Efficient XML generation with minimal memory footprint
Use Cases
Standards Compliance
PHP FacturaE generates XML that:- ✅ Validates against official FacturaE XSD schemas
- ✅ Passes FACe validation
- ✅ Supports XAdES-EPES signatures with TSA timestamping
- ✅ Compatible with public administration portals (FACe, FACeB2B)
Getting Started
Installation
Install via Composer and configure your environment
Quickstart Guide
Create your first invoice in under 5 minutes
Architecture
The library is organized into focused namespaces:Invoice— Main entry point with fluent APIParty— Seller/buyer entities (companies and individuals)Entities/— Line items, payments, attachments, tax breakdowns, addressesEnums/— Tax types, payment methods, invoice types, correction reasonsExporter/— XML generationSigner/— XAdES-EPES digital signaturesValidation/— Schema validation
Every class uses readonly properties and strict types (PHP 8.2+) for maximum safety and IDE autocomplete support.
Next Steps
Install the library
Follow the installation guide to add PHP FacturaE to your project
Generate your first invoice
Complete the quickstart tutorial to create a working invoice