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.
CfdiCreator33 mirrors CfdiCreator40 in every respect — the same constructor signature, the same helper methods, and the same underlying CfdiCreatorTrait — but it targets the CFDI version 3.3 namespace and element set (CfdiUtils\Elements\Cfdi33\Comprobante). All the general creation rules documented for CFDI 4.0 apply equally here; the only differences are the namespace URIs, the element classes used, and the XSLT location resolved when generating the cadena de origen.
Constructor
Key/value pairs set as attributes on the root
cfdi:Comprobante element. Fixed attributes (Version, xmlns:cfdi, xsi:schemaLocation) are set automatically by the Cfdi33\Comprobante element.An optional
CfdiUtils\Certificado\Certificado instance. When provided, putCertificado() is called immediately at construction time.Manages local caching of SAT XSD and XSLT resources. Defaults to a new
XmlResolver with SAT remote URLs.The XSLT engine used to build the cadena de origen. Defaults to
CfdiUtils\CadenaOrigen\DOMBuilder.Methods
CfdiCreator33 exposes the same methods as CfdiCreator40, all provided by the shared CfdiCreatorTrait:
| Method | Description |
|---|---|
comprobante(): Comprobante | Returns the CfdiUtils\Elements\Cfdi33\Comprobante root element. |
putCertificado(Certificado $cert, bool $putEmisorRfcNombre = true): void | Writes NoCertificado and Certificado attributes; optionally sets Emisor.Rfc and Emisor.Nombre. |
asXml(): string | Serializes the element tree to an XML string. |
saveXml(string $filename): bool | Writes the XML to a file. |
buildCadenaDeOrigen(): string | Applies the CFDI 3.3 XSLT and returns the cadena de origen string. |
buildSumasConceptos(int $precision = 2): SumasConceptos | Computes totals from the Conceptos without writing them. |
addSumasConceptos(?SumasConceptos $sumas = null, int $precision = 2): void | Computes and writes totals to SubTotal, Total, Descuento, and Impuestos. |
addSello(string $key, string $passPhrase = ''): void | Signs the document and stores the Base64 signature in the Sello attribute. |
validate(): Asserts | Runs the CFDI 3.3 validation suite (MultiValidatorFactory::newCreated33()). |
moveSatDefinitionsToComprobante(): void | Moves all namespace declarations to the root node. |
Key Differences from CFDI 4.0
| Aspect | CFDI 3.3 | CFDI 4.0 |
|---|---|---|
| Creator class | CfdiUtils\CfdiCreator33 | CfdiUtils\CfdiCreator40 |
| Element namespace | CfdiUtils\Elements\Cfdi33 | CfdiUtils\Elements\Cfdi40 |
| XML namespace URI | http://www.sat.gob.mx/cfd/3 | http://www.sat.gob.mx/cfd/4 |
| Schema location | .../cfd/3/cfdv33.xsd | .../cfd/4/cfdv40.xsd |
| XSLT location | .../cadenaoriginal_3_3/cadenaoriginal_3_3.xslt | .../cadenaoriginal_4_0/cadenaoriginal_4_0.xslt |
| Emisor suffix trim | Not applied | Applied for 12-char RFC |
| SAT status | Suspended | Current standard |
Migrating from CFDI 3.3 to 4.0 within CfdiUtils is straightforward: replace every reference to
CfdiUtils\Elements\Cfdi33 with CfdiUtils\Elements\Cfdi40 and swap CfdiCreator33 for CfdiCreator40. Then adjust attribute names and values to match the SAT’s CFDI 4.0 specification (the library’s element compatibility layer minimises the breaking surface).Basic Usage Example
Upgrade to CFDI 4.0
CFDI 3.3 has been suspended by the SAT. Follow the CFDI 4.0 guide to migrate your integration to the current standard.