CfdiUtils (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eclipxe13/CfdiUtils/llms.txt
Use this file to discover all available pages before exploring further.
eclipxe/cfdiutils) is a PHP library that provides everything developers need to work with Mexican electronic invoices (CFDI). Rather than building XML by hand or wrestling with SAT’s schemas and XSLT transformations, CfdiUtils gives you a clean, object-oriented API for the entire invoice lifecycle: creating CFDI structures, reading existing documents, validating against official schemas, generating the cadena de origen, working with certificates, and querying the SAT web service for document status.
What is CFDI?
CFDI (Comprobante Fiscal Digital por Internet) is Mexico’s mandatory electronic invoicing standard, governed by the Servicio de Administración Tributaria (SAT) — Mexico’s tax authority. Every business that issues or receives invoices in Mexico must produce and process CFDI documents that conform to the SAT’s technical specifications: XML schemas (XSD), digital signature rules, XSLT-based chain generation, and certificate management. For PHP developers, implementing all of these requirements from scratch is a significant undertaking. The specifications run to hundreds of pages, the schemas are versioned, and the signature process involves specific OpenSSL operations tied to the SAT’s certificate infrastructure. CfdiUtils abstracts all of this behind a well-tested, maintained library, letting you focus on your application’s business logic.Library Overview
CfdiUtils is a comprehensive toolkit that covers every phase of working with CFDI documents:- Creating CFDI — build CFDI 3.3 and 4.0 documents using friendly, extensible node objects without writing raw XML
- Reading CFDI — parse and extract data from CFDI versions 3.2, 3.3, and 4.0, including a
QuickReaderfor fast lookups - Validating CFDI — validate documents against official XSD schemas, verify the
Sellodigital signature, and apply custom business rules for CFDI 3.3 and 4.0 - Cadena de Origen — generate the canonical string used during signing via XSLT transformation
- Certificate handling — read and inspect CER files, extract serial numbers, RFC, and certificate contents
- SAT resource caching — maintain a local copy of all XSD and XSLT dependencies from the SAT to avoid repeated network downloads
- SAT status queries — call the SAT web service to retrieve a CFDI’s
Estado,EsCancelable,EstatusCancelacion, andEFOSstatus without needing a WSDL file
Supported CFDI Versions
| CFDI Version | Reading | Validation | Creation |
|---|---|---|---|
| 3.2 | ✅ | ❌ | ❌ |
| 3.3 | ✅ | ✅ | ✅ |
| 4.0 | ✅ | ✅ | ✅ |
PHP Requirements
CfdiUtils requires PHP 8.0 or higher. The following PHP extensions are required and must be enabled in your environment:| Extension | Purpose |
|---|---|
libxml | XML parsing foundation |
dom | DOM document manipulation |
xsl | XSLT transformations (cadena de origen) |
simplexml | Simple XML reading |
mbstring | Multi-byte string operations |
openssl | Certificate handling and digital signing |
iconv | Character encoding conversion |
json | JSON encoding/decoding |
| Extension / Package | Feature unlocked |
|---|---|
ext-bcmath | Precise total and tax calculation for Pagos 2.0 complement |
ext-soap | Consume the SAT CFDI status web service |
genkgo/xsl | Use Genkgo XSL as an alternative XSLT v2 processor |
Versioning
The library follows semantic versioning. The current stable release series is 3.x, which targets PHP 8.0 and above and was released in March 2025 primarily to ensure compatibility with PHP 8.4. Version 4.x is planned for the future and may introduce backward-incompatible changes.This project will eventually be migrated to
phpcfdi/cfdiutils under the phpCfdi organization. No migration date has been set yet. Visit phpcfdi.com for related libraries and SAT tooling from the same community.Quickstart
Install the library and create, sign, and validate your first CFDI 4.0 in minutes.
Installation
Detailed installation instructions, PHP extension requirements, and upgrade notes.
Reading CFDI
Learn how to parse and extract data from existing CFDI 3.2, 3.3, and 4.0 documents.
Validation
Validate CFDI documents against XSD schemas, check digital signatures, and apply custom rules.