PHP FacturaE
Open-source PHP library to generate, sign and export FacturaE electronic invoices. Fluent API, XAdES-EPES signature, zero dependencies.
6 lines. One signed invoice.
Invoice::create('FAC-001') ->seller(Party::company('B12345678', 'My Company S.L.')) ->buyer(Party::person('12345678Z', 'Laura', 'Gómez', 'Ruiz')) ->line('Logo design', price: 450.00, vat: 21) ->sign(Signer::pfx('certificate.pfx', 'password')) ->export('invoice.xsig');That’s PHP FacturaE. Electronic invoicing in PHP, without the hassle.
No endless configuration. No external dependencies. No weeks of development.
The problem it solves
Spanish companies are required to issue electronic invoices for the tax agency (AEAT) and FACe. Integrating that into a web application usually takes weeks: dense specs, digital certificates, and XML that nobody wants to write by hand.
PHP FacturaE cuts it down to an afternoon.
I built it because at AtlanTIC Systems we needed electronic invoicing for several projects — ERPs, SaaS platforms, integrations with public administrations — and there was nothing in PHP that was modern, typed and easy to use.
Every tax scenario
VAT, IGIC for the Canary Islands, IRPF withholdings, equivalence surcharge, exemptions… Every tax case is solved with a clear method:
->line('Product', price: 100, vat: 21)->line('Professional service', price: 500, vat: 21, irpf: 15)->line('Canary Islands product', price: 100, igic: 7)->line('Jewelry', price: 200, vat: 21, surcharge: 5.2)->exemptLine('Training', price: 2000, reason: 'Art. 20.Uno.9')29 tax types covered. The developer writes what they know about the business, the library generates the correct XML.
Companies, self-employed and foreign entities
// Spanish companyParty::company('B12345678', 'Company S.L.') ->address('C/ Mayor 10', '28013', 'Madrid', 'Madrid')
// Self-employedParty::person('12345678Z', 'Laura', 'Gómez', 'Ruiz') ->address('C/ Sol 3', '28012', 'Madrid', 'Madrid')
// Foreign companyParty::company('FR12345678901', 'Entreprise SAS') ->address('12 Rue de la Paix', '75002', 'Paris', 'Île-de-France', 'FRA')It also supports invoicing to the Public Administration with FACe administrative centers (DIR3).
Digital signature in one line
The most complex part of FacturaE — certificates, XAdES-EPES, XML canonicalization — solved in a single call:
->sign(Signer::pfx('certificate.pfx', 'password'))Compatible with PKCS#12 and PEM certificates. Time-stamping (TSA) option for long-term validity.
Split payments
Transfer, card, direct debit, cash… and automatic installment payments:
->splitPayments( method: PaymentMethod::Transfer, installments: 3, firstDueDate: '2025-04-01', intervalDays: 30, iban: 'ES91 2100 0418 4502 0005 1332',)19 payment methods. Automatic cent distribution in the last installment.
Corrective invoices
Corrections with legal reason and tax period, all typed with enums:
->corrects( invoiceNumber: 'FAC-001', reason: CorrectionReason::TaxableBase, method: CorrectionMethod::FullReplacement, periodStart: '2025-01-01', periodEnd: '2025-03-31',)22 official correction reasons.
What’s included
| 29 taxes | VAT, IGIC, IRPF, equivalence surcharge, exemptions… |
| 19 payment methods | Transfer, card, direct debit, cash, installments… |
| Digital signature | XAdES-EPES with PKCS#12, PEM and time-stamping |
| Corrective invoices | 22 correction reasons + tax period |
| Attachments | PDFs, contracts or documents embedded in the invoice |
| Official validation | FacturaE 3.2, 3.2.1 and 3.2.2 |
| Public Administration | FACe administrative centers (DIR3) |
Performance
| 1 invoice | ~0.2 ms |
| 100 invoices | ~22 ms |
Zero external dependencies. Just standard PHP (ext-openssl + ext-dom).
Technical decisions
PHP FacturaE is not a wrapper over another library. I designed it from scratch with a clean architecture:
- Fluent API with immutability — Each method returns
self, but the internal state usesreadonlyproperties wherever possible. - Native PHP 8.2 enums — No loose constants or associative arrays. The 29 taxes, 19 payment methods and 22 correction reasons are all typed enums.
- Automatic validation — The XML is validated against the official XSD schemas before export. If something is missing, the exception says exactly what.
- XAdES-EPES signature — Own implementation with no external libraries, with support for RFC 3161 time-stamping.
- PHPStan level 8 — Maximum-level static analysis across the entire source.
Open Source
PHP FacturaE is open source under the MIT license.
composer require php-facturae/php-facturae