PHPackages                             php-facturae/php-facturae - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. php-facturae/php-facturae

ActiveLibrary[Payment Processing](/categories/payments)

php-facturae/php-facturae
=========================

Generate, sign and export FacturaE electronic invoices in PHP 8.2+ — fluent API, XAdES-EPES signing, zero dependencies. Genera y firma facturas electrónicas.

v1.0.0(3mo ago)09MITPHPPHP ^8.2CI passing

Since Mar 4Pushed 3mo agoCompare

[ Source](https://github.com/MarioDevv/php-facturae)[ Packagist](https://packagist.org/packages/php-facturae/php-facturae)[ Docs](https://github.com/php-facturae/php-facturae)[ GitHub Sponsors](https://github.com/sponsors/php-facturae)[ RSS](/packages/php-facturae-php-facturae/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

PhpFacturae
===========

[](#phpfacturae)

[![Tests](https://github.com/MarioDevv/php-facturae/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/php-facturae/php-facturae/actions/workflows/php.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/d6306a0cf99323d2d5db7b2fbde2549017ac4f09ff1e78f7dd0fa783dfd10a3e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d66616374757261652f7068702d66616374757261652e737667)](https://packagist.org/packages/php-facturae/php-facturae)[![Total Downloads](https://camo.githubusercontent.com/b215f7d82a065a5e7ea7fcfa765343a73fd3e26e6bfed495d5f42afc12ae0907/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d66616374757261652f7068702d66616374757261652e737667)](https://packagist.org/packages/php-facturae/php-facturae)[![PHP](https://camo.githubusercontent.com/8f0af9c5395ae4ef8ba7a7ad65fa61c44927ea9c3eb3be91a13c678254f29bd4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e322d383839324246)](composer.json)[![PHPStan](https://camo.githubusercontent.com/44dc5f71fec76653887c975fe3db546a82ff603d094798eb6414a38369db1f44/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068707374616e2d6c6576656c253230382d627269676874677265656e)](phpstan.neon)[![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)](LICENSE)

Librería PHP moderna para generar, firmar y exportar **facturas electrónicas** en formato [FacturaE](http://www.facturae.gob.es/) (3.2, 3.2.1, 3.2.2) con firma **XAdES-EPES** — sin dependencias externas.

> La alternativa moderna a [Facturae-PHP](https://github.com/josemmo/Facturae-PHP): API fluent con named arguments, enums nativos de PHP 8.2+, tipado estricto y PHPStan nivel 8.

```
use PhpFacturae\Invoice;
use PhpFacturae\Party;
use PhpFacturae\Signer;

Invoice::create('FAC-001')
    ->series('A')
    ->date('2025-03-01')
    ->seller(Party::company('B12345674', 'Mi Empresa S.L.')
        ->address('C/ Mayor 10', '28013', 'Madrid', 'Madrid'))
    ->buyer(Party::person('12345678Z', 'Laura', 'Gómez', 'Ruiz')
        ->address('C/ Sol 3', '28012', 'Madrid', 'Madrid'))
    ->line('Diseño logotipo', price: 450.00, vat: 21)
    ->transferPayment(iban: 'ES91 2100 0418 4502 0005 1332', dueDate: '2025-03-31')
    ->sign(Signer::pfx('certificado.pfx', 'password'))
    ->export('factura.xsig');
```

¿Por qué PhpFacturae?
---------------------

[](#por-qué-phpfacturae)

**PhpFacturae**josemmo/facturae-phpAPIFluent con named argumentsArrays asociativosPHP mínimo8.2+ con enums y readonly5.6+TipadoEstricto · PHPStan nivel 8Sin análisis estáticoImpuestosNamed args: `vat:`, `igic:`, `irpf:`Constantes: `TAX_IVA` + arraysDependenciasCero (solo ext-dom, ext-openssl)CeroRendimiento~0.2 ms / factura—Instalación
-----------

[](#instalación)

```
composer require php-facturae/php-facturae
```

Requiere **PHP 8.2+** con `ext-openssl` (firma), `ext-dom` (XML) y `ext-curl` (TSA, opcional).

Uso rápido
----------

[](#uso-rápido)

### Líneas e impuestos

[](#líneas-e-impuestos)

```
->line('Producto', price: 100, vat: 21)                          // IVA 21 %
->line('Servicio profesional', price: 500, vat: 21, irpf: 15)    // IVA + retención IRPF
->line('Producto canario', price: 100, igic: 7)                  // IGIC 7 %
->line('Joyería', price: 200, vat: 21, surcharge: 5.2)           // IVA + recargo equivalencia
->exemptLine('Formación', price: 2000, reason: 'Art. 20.Uno.9')  // Exenta
```

Para combinaciones más específicas, `customLine` acepta un array de `TaxBreakdown`:

```
->customLine('Producto canario', price: 300, taxes: [
    new TaxBreakdown(Tax::IGIC, 7),
    new TaxBreakdown(Tax::REIGIC, 0.5),
])
```

### Partes (emisor / receptor)

[](#partes-emisor--receptor)

```
// Persona jurídica
Party::company('B12345674', 'Empresa S.L.')
    ->tradeName('Nombre Comercial')
    ->address('C/ Mayor 10', '28013', 'Madrid', 'Madrid')
    ->email('admin@empresa.es')
    ->merchantRegister(book: '1', register: 'Madrid', sheet: 'T-12345', folio: '100')

// Persona física
Party::person('12345678Z', 'Laura', 'Gómez', 'Ruiz')
    ->address('C/ Sol 3', '28012', 'Madrid', 'Madrid')

// Extranjero
Party::company('FR12345678901', 'Entreprise SAS')
    ->address('12 Rue de la Paix', '75002', 'Paris', 'Île-de-France', 'FRA')
```

Centros administrativos para FACe:

```
Party::company('S2800000A', 'Ministerio de Ejemplo')
    ->address('C/ Oficial 1', '28001', 'Madrid', 'Madrid')
    ->centre('01', 'L01234567', 'Oficina contable')
    ->centre('02', 'L01234567', 'Órgano gestor')
    ->centre('03', 'L01234567', 'Unidad tramitadora')
```

### Pagos

[](#pagos)

```
->transferPayment(iban: 'ES91...', dueDate: '2025-04-01')
->cashPayment(dueDate: '2025-03-01')
->cardPayment(dueDate: '2025-03-01')
->directDebitPayment(iban: 'ES80...', dueDate: '2025-03-10')
```

Pagos fraccionados (divide el total en N plazos, ajusta céntimos en el último):

```
->splitPayments(
    method: PaymentMethod::Transfer,
    installments: 3,
    firstDueDate: '2025-04-01',
    intervalDays: 30,
    iban: 'ES91...',
)
```

### Descuentos y cargos

[](#descuentos-y-cargos)

```
->generalDiscount('Cliente VIP', rate: 5)
->generalDiscount('Promoción', amount: 50.00)
->generalCharge('Portes', amount: 15.00)
```

### Rectificativas

[](#rectificativas)

```
->corrects(
    invoiceNumber: 'FAC-001',
    reason: CorrectionReason::TaxableBase,
    method: CorrectionMethod::FullReplacement,
    series: 'A',
    periodStart: '2025-01-01',
    periodEnd: '2025-03-31',
)
```

22 motivos en `CorrectionReason`, 4 métodos en `CorrectionMethod`.

### Adjuntos

[](#adjuntos)

```
->attachFile('/path/to/contrato.pdf', 'Contrato firmado')
->attach(Attachment::fromData($rawPdf, 'application/pdf', 'Albarán'))
```

### Firma electrónica XAdES

[](#firma-electrónica-xades)

```
// PKCS#12
->sign(Signer::pfx('certificado.pfx', 'password'))

// PEM
->sign(Signer::pem('cert.pem', 'key.pem'))

// Con sellado de tiempo TSA
->sign(Signer::pfx('certificado.pfx', 'password')->timestamp('https://freetsa.org/tsr'))
```

También firma XMLs generados por otros programas:

```
$signedXml = Pkcs12Signer::pfx('cert.pfx', 'pass')->sign(file_get_contents('factura.xml'));
```

### Otros

[](#otros)

```
->schema(Schema::V3_2_2)                                  // Versión XSD (por defecto 3.2.2)
->operationDate('2025-02-28')                              // Fecha operación (devengo)
->billingPeriod(from: '2025-02-01', to: '2025-02-28')     // Periodo facturación
->legalLiteral('Factura exenta de IVA por aplicación del REF Canario.')
```

Features
--------

[](#features)

- XML FacturaE 3.2 / 3.2.1 / 3.2.2
- Firma XAdES-EPES + sellado de tiempo TSA
- 29 impuestos · 19 métodos de pago · 36 unidades de medida
- Multi-impuesto por línea, recargo de equivalencia
- Operaciones exentas y no sujetas
- Facturas rectificativas (22 motivos + periodo fiscal)
- Descuentos y cargos generales
- Adjuntos embebidos (PDF, imágenes, etc.)
- Pagos fraccionados con ajuste de céntimos
- Personas físicas / jurídicas / extranjeros
- Centros administrativos FACe (DIR3)
- PHPStan nivel 8 · CI con PHP 8.2, 8.3 y 8.4
- Envío directo a FACe (AAPP)
- Envío a FACeB2B
- Suplidos
- Cesionarios (factoring)
- Terceros (third-party issuer)

Contribuir
----------

[](#contribuir)

```
git clone https://github.com/php-facturae/php-facturae.git
cd php-facturae
composer install
vendor/bin/phpunit
vendor/bin/phpstan analyse src --level=8
```

¿Encontraste un bug? [Abre un issue](https://github.com/php-facturae/php-facturae/issues). ¿Quieres aportar código? Los PRs son bienvenidos.

Licencia
--------

[](#licencia)

[MIT](LICENSE) © Mario Pérez

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance80

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

106d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/90867187?v=4)[Mario](/maintainers/MarioDevv)[@MarioDevv](https://github.com/MarioDevv)

---

Top Contributors

[![MarioDevv](https://avatars.githubusercontent.com/u/90867187?v=4)](https://github.com/MarioDevv "MarioDevv (27 commits)")

---

Tags

e-invoicingelectronic-invoicefactura-electronicafacturaelaravelphpspainspanish-taxxadesxmlsigninginvoiceE-Invoicetaxelectronic invoicefacefacturaexadesfaceb2bspanishe-invoicingspainaeatfactura-electronicaivafiscalxades-epesxml-signingIRPFpkcs12facturae-phpigicphp-facturae

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-facturae-php-facturae/health.svg)

```
[![Health](https://phpackages.com/badges/php-facturae-php-facturae/health.svg)](https://phpackages.com/packages/php-facturae-php-facturae)
```

###  Alternatives

[num-num/ubl-invoice

A modern object-oriented PHP library to create and read valid UBL and EN 16931/Peppol BIS 3.0 files

136887.1k](/packages/num-num-ubl-invoice)[josemmo/facturae-php

Librería para la generación, firma y envío de facturas electrónicas

285592.9k2](/packages/josemmo-facturae-php)[saleh7/php-zatca-xml

An unofficial PHP library for generating ZATCA Fatoora e-invoices. This library facilitates the creation of compliant e-invoices, QR Codes, and certificates, as well as the submission of e-invoices to ZATCA's servers. It provides developers with an easy-to-use, customizable, and robust toolkit to integrate and automate ZATCA e-invoicing processes in PHP applications.

5516.0k](/packages/saleh7-php-zatca-xml)[cleverit/ubl_invoice

A PHP wrapper for UBL invoices

36286.3k](/packages/cleverit-ubl-invoice)[atgp/factur-x

PHP library to manage your Factur-X / ZUGFeRD 2.0 PDF invoices files

149883.7k4](/packages/atgp-factur-x)[sevaske/php-zatca-xml

An unofficial PHP library for generating ZATCA Fatoora e-invoices. This library facilitates the creation of compliant e-invoices, QR Codes, and certificates, as well as the submission of e-invoices to ZATCA's servers. It provides developers with an easy-to-use, customizable, and robust toolkit to integrate and automate ZATCA e-invoicing processes in PHP applications.

218.1k1](/packages/sevaske-php-zatca-xml)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
