Skip to content

Commit d1a1dc1

Browse files
committed
Update -> Readme && keywords
1 parent 882c0e7 commit d1a1dc1

2 files changed

Lines changed: 88 additions & 80 deletions

File tree

README.md

Lines changed: 64 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,61 @@
1-
# Rex
1+
# PhpFacturae
22

3-
[![Tests](https://github.com/MarioDevv/rex/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/MarioDevv/rex/actions/workflows/php.yml)
3+
[![Tests](https://github.com/php-facturae/php-facturae/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/php-facturae/php-facturae/actions/workflows/php.yml)
4+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/php-facturae/php-facturae.svg)](https://packagist.org/packages/php-facturae/php-facturae)
5+
[![Total Downloads](https://img.shields.io/packagist/dt/php-facturae/php-facturae.svg)](https://packagist.org/packages/php-facturae/php-facturae)
46
[![PHP](https://img.shields.io/badge/php-%3E%3D8.2-8892BF)](composer.json)
7+
[![PHPStan](https://img.shields.io/badge/phpstan-level%208-brightgreen)](phpstan.neon)
58
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
69

7-
Genera, firma y exporta facturas electrónicas en formato [FacturaE](http://www.facturae.gob.es/) con una API fluent y type-safe.
10+
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.
11+
12+
> 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.
813
914
```php
15+
use PhpFacturae\Invoice;
16+
use PhpFacturae\Party;
17+
use PhpFacturae\Signer;
18+
1019
Invoice::create('FAC-001')
1120
->series('A')
1221
->date('2025-03-01')
13-
->seller(Party::company('B12345678', 'Mi Empresa S.L.')->address('C/ Mayor 10', '28013', 'Madrid', 'Madrid'))
14-
->buyer(Party::person('12345678Z', 'Laura', 'Gómez', 'Ruiz')->address('C/ Sol 3', '28012', 'Madrid', 'Madrid'))
22+
->seller(Party::company('B12345674', 'Mi Empresa S.L.')
23+
->address('C/ Mayor 10', '28013', 'Madrid', 'Madrid'))
24+
->buyer(Party::person('12345678Z', 'Laura', 'Gómez', 'Ruiz')
25+
->address('C/ Sol 3', '28012', 'Madrid', 'Madrid'))
1526
->line('Diseño logotipo', price: 450.00, vat: 21)
1627
->transferPayment(iban: 'ES91 2100 0418 4502 0005 1332', dueDate: '2025-03-31')
1728
->sign(Signer::pfx('certificado.pfx', 'password'))
1829
->export('factura.xsig');
1930
```
2031

21-
## Highlights
32+
## ¿Por qué PhpFacturae?
2233

23-
- **Fluent API con enums** — nada de arrays asociativos ni constantes sueltas
24-
- **Firma XAdES-EPES** — con sellado de tiempo TSA incluido (PKCS#12 y PEM)
25-
- **Validado contra XSD** — FacturaE 3.2, 3.2.1 y 3.2.2
26-
- **Cero dependencias** — solo extensiones estándar de PHP (`openssl`, `dom`)
27-
- **29 impuestos, 19 métodos de pago, 36 unidades de medida**
28-
- **~0.2 ms** por factura simple, ~22 ms para 100 facturas
34+
| | **PhpFacturae** | josemmo/facturae-php |
35+
|---|---|---|
36+
| API | Fluent con named arguments | Arrays asociativos |
37+
| PHP mínimo | 8.2+ con enums y readonly | 5.6+ |
38+
| Tipado | Estricto · PHPStan nivel 8 | Sin análisis estático |
39+
| Impuestos | Named args: `vat:`, `igic:`, `irpf:` | Constantes: `TAX_IVA` + arrays |
40+
| Dependencias | Cero (solo ext-dom, ext-openssl) | Cero |
41+
| Rendimiento | ~0.2 ms / factura ||
2942

3043
## Instalación
3144

3245
```bash
33-
composer require mariodevv/rex
46+
composer require php-facturae/php-facturae
3447
```
3548

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

38-
## Uso
51+
## Uso rápido
3952

4053
### Líneas e impuestos
4154

4255
```php
43-
->line('Producto', price: 100, vat: 21) // IVA 21%
56+
->line('Producto', price: 100, vat: 21) // IVA 21 %
4457
->line('Servicio profesional', price: 500, vat: 21, irpf: 15) // IVA + retención IRPF
45-
->line('Producto canario', price: 100, igic: 7) // IGIC 7%
58+
->line('Producto canario', price: 100, igic: 7) // IGIC 7 %
4659
->line('Joyería', price: 200, vat: 21, surcharge: 5.2) // IVA + recargo equivalencia
4760
->exemptLine('Formación', price: 2000, reason: 'Art. 20.Uno.9') // Exenta
4861
```
@@ -59,16 +72,19 @@ Para combinaciones más específicas, `customLine` acepta un array de `TaxBreakd
5972
### Partes (emisor / receptor)
6073

6174
```php
62-
Party::company('B12345678', 'Empresa S.L.') // Persona jurídica
75+
// Persona jurídica
76+
Party::company('B12345674', 'Empresa S.L.')
6377
->tradeName('Nombre Comercial')
6478
->address('C/ Mayor 10', '28013', 'Madrid', 'Madrid')
6579
->email('admin@empresa.es')
6680
->merchantRegister(book: '1', register: 'Madrid', sheet: 'T-12345', folio: '100')
6781

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

71-
Party::company('FR12345678901', 'Entreprise SAS') // Extranjero
86+
// Extranjero
87+
Party::company('FR12345678901', 'Entreprise SAS')
7288
->address('12 Rue de la Paix', '75002', 'Paris', 'Île-de-France', 'FRA')
7389
```
7490

@@ -133,12 +149,17 @@ Pagos fraccionados (divide el total en N plazos, ajusta céntimos en el último)
133149
->attach(Attachment::fromData($rawPdf, 'application/pdf', 'Albarán'))
134150
```
135151

136-
### Firma
152+
### Firma electrónica XAdES
137153

138154
```php
139-
->sign(Signer::pfx('certificado.pfx', 'password')) // PKCS#12
140-
->sign(Signer::pem('cert.pem', 'key.pem')) // PEM
141-
->sign(Signer::pfx('certificado.pfx', 'password')->timestamp('https://freetsa.org/tsr')) // + TSA
155+
// PKCS#12
156+
->sign(Signer::pfx('certificado.pfx', 'password'))
157+
158+
// PEM
159+
->sign(Signer::pem('cert.pem', 'key.pem'))
160+
161+
// Con sellado de tiempo TSA
162+
->sign(Signer::pfx('certificado.pfx', 'password')->timestamp('https://freetsa.org/tsr'))
142163
```
143164

144165
También firma XMLs generados por otros programas:
@@ -150,78 +171,45 @@ $signedXml = Pkcs12Signer::pfx('cert.pfx', 'pass')->sign(file_get_contents('fact
150171
### Otros
151172

152173
```php
153-
->schema(Schema::V3_2_2) // Versión XSD (default 3.2.2)
154-
->operationDate('2025-02-28') // Fecha operación
174+
->schema(Schema::V3_2_2) // Versión XSD (por defecto 3.2.2)
175+
->operationDate('2025-02-28') // Fecha operación (devengo)
155176
->billingPeriod(from: '2025-02-01', to: '2025-02-28') // Periodo facturación
177+
->legalLiteral('Factura exenta de IVA por aplicación del REF Canario.')
156178
```
157179

158-
## Validación
159-
160-
Los XMLs se validan contra el [XSD oficial 3.2.2](http://www.facturae.gob.es/formato/Paginas/version-3-2.aspx) y en el [validador de FACe](https://face.gob.es/es/facturas/validar-visualizar-factura):
161-
162-
```bash
163-
xmllint --schema Facturaev3_2_2.xsd dist/factura-completa.xsig --noout
164-
```
165-
166-
## Roadmap
180+
## Features
167181

168182
- [x] XML FacturaE 3.2 / 3.2.1 / 3.2.2
169-
- [x] 29 impuestos · 19 métodos de pago · 36 unidades
170-
- [x] Multi-impuesto por línea, recargo equivalencia
171-
- [x] Operaciones exentas y no sujetas
172-
- [x] Rectificativas (22 motivos + periodo fiscal)
173183
- [x] Firma XAdES-EPES + sellado de tiempo TSA
184+
- [x] 29 impuestos · 19 métodos de pago · 36 unidades de medida
185+
- [x] Multi-impuesto por línea, recargo de equivalencia
186+
- [x] Operaciones exentas y no sujetas
187+
- [x] Facturas rectificativas (22 motivos + periodo fiscal)
174188
- [x] Descuentos y cargos generales
175-
- [x] Adjuntos embebidos
176-
- [x] Pagos fraccionados
177-
- [x] Personas físicas/jurídicas, extranjeros, centros FACe
178-
- [ ] Envío a FACe (AAPP)
189+
- [x] Adjuntos embebidos (PDF, imágenes, etc.)
190+
- [x] Pagos fraccionados con ajuste de céntimos
191+
- [x] Personas físicas / jurídicas / extranjeros
192+
- [x] Centros administrativos FACe (DIR3)
193+
- [x] PHPStan nivel 8 · CI con PHP 8.2, 8.3 y 8.4
194+
- [ ] Envío directo a FACe (AAPP)
179195
- [ ] Envío a FACeB2B
180196
- [ ] Suplidos
181197
- [ ] Cesionarios (factoring)
182198
- [ ] Terceros (third-party issuer)
183-
- [ ] Precisión configurable (redondeo por línea vs factura)
184-
185-
## Estructura del proyecto
186-
187-
```
188-
src/Facturae/
189-
├── Entities/ Address, Attachment, Line, Payment, TaxBreakdown
190-
├── Enums/ Tax (29), PaymentMethod (19), UnitOfMeasure (36),
191-
│ CorrectionReason (22), CorrectionMethod, Schema, ...
192-
├── Exceptions/ InvoiceValidationException, InvalidPostalCodeException
193-
├── Exporter/ XmlExporter
194-
├── Signer/ InvoiceSigner (interface), Pkcs12Signer
195-
├── Validation/ InvoiceValidator
196-
├── Invoice.php Entry point
197-
├── Party.php Emisor / receptor
198-
└── Signer.php Facade
199-
200-
tests/Facturae/
201-
├── Mother/ InvoiceMother (14 escenarios Object Mother)
202-
├── InvoiceTest.php
203-
├── LineTest.php
204-
├── PartyTest.php
205-
├── GenerateRealInvoiceTest.php
206-
└── XmlExportBenchmarkTest.php
207-
```
208-
209-
## Inspiración
210-
211-
Rex nace como alternativa moderna a [Facturae-PHP](https://github.com/josemmo/Facturae-PHP) de josemmo, referencia durante años para la facturación electrónica en PHP. Si buscas una solución madura y probada en producción, su librería es una apuesta segura.
212199

213200
## Contribuir
214201

215202
```bash
216-
git clone https://github.com/MarioDevv/rex.git
217-
cd rex
203+
git clone https://github.com/php-facturae/php-facturae.git
204+
cd php-facturae
218205
composer install
219206
vendor/bin/phpunit
207+
vendor/bin/phpstan analyse src --level=8
220208
```
221209

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

225213
## Licencia
226214

227-
[MIT](LICENSE)
215+
[MIT](LICENSE) © Mario Pérez

composer.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,53 @@
11
{
22
"name": "php-facturae/php-facturae",
3-
"description": "Generate, validate and sign FacturaE (3.2.x) electronic invoices in PHP — the modern alternative for Spanish e-invoicing",
3+
"description": "Generate, sign and export FacturaE electronic invoices in PHP 8.2+ — fluent API, XAdES-EPES signing, zero dependencies. Genera y firma facturas electrónicas.",
44
"type": "library",
55
"license": "MIT",
66
"keywords": [
77
"facturae",
8+
"facturae-php",
89
"factura-electronica",
910
"electronic-invoice",
11+
"e-invoicing",
1012
"e-invoice",
1113
"spain",
14+
"spanish",
1215
"fiscal",
1316
"xades",
17+
"xades-epes",
1418
"xml",
19+
"xml-signing",
1520
"aeat",
1621
"tax",
1722
"invoice",
1823
"signing",
19-
"php-facturae",
20-
"facturae-php"
24+
"pkcs12",
25+
"face",
26+
"faceb2b",
27+
"iva",
28+
"igic",
29+
"irpf",
30+
"php-facturae"
2131
],
2232
"homepage": "https://github.com/php-facturae/php-facturae",
2333
"authors": [
2434
{
2535
"name": "Mario Pérez",
2636
"email": "perezmario.info@gmail.com",
37+
"homepage": "https://mariodevv.com",
2738
"role": "Lead Developer"
2839
}
2940
],
3041
"support": {
3142
"issues": "https://github.com/php-facturae/php-facturae/issues",
3243
"source": "https://github.com/php-facturae/php-facturae"
3344
},
45+
"funding": [
46+
{
47+
"type": "github",
48+
"url": "https://github.com/sponsors/php-facturae"
49+
}
50+
],
3451
"require": {
3552
"php": "^8.2",
3653
"ext-openssl": "*",
@@ -54,5 +71,8 @@
5471
"test": "phpunit",
5572
"analyse": "phpstan analyse src --level=8"
5673
},
57-
"minimum-stability": "stable"
74+
"minimum-stability": "stable",
75+
"config": {
76+
"sort-packages": true
77+
}
5878
}

0 commit comments

Comments
 (0)