nfephp-org/sped-nfe
Biblioteca PHP para gerar, assinar e comunicar NF-e (55) e NFC-e (65) com as SEFAZ. Suporta todos os estados, emissão com eCPF (com exceções), envio síncrono e atualizações conforme notas técnicas e schemas recentes do SPED NF-e.
nfephp-org/sped-nfe package is a domain-specific solution for generating and communicating Brazilian Electronic Invoices (NF-e) with SEFAZ (state tax authorities). It fits well in architectures where:
nfeProc, eventos) are asynchronous—the package supports webhook-style callbacks, but the TPM must design for idempotency and retry logic (e.g., failed validations).SimpleXMLElement or spatie/array-to-xml).| Risk Area | Description | Mitigation Strategy |
|---|---|---|
| Deprecated Package | No updates since 2020; may break with PHP 8.x or SEFAZ 5.0+ changes. | Fork the repo, backport fixes, or evaluate alternatives (e.g., nfephp/nfe). |
| SEFAZ API Changes | SEFAZ frequently updates schemas (e.g., new tags, deprecated fields). | Implement schema versioning in the app and monitor SEFAZ announcements. |
| Error Handling | SEFAZ returns cryptic XML errors (e.g., cStat=500). |
Build a translator layer to map SEFAZ errors to user-friendly messages. |
| Performance | XML generation/parsing can be slow for high-volume NF-es. | Cache frequently used NF-e templates; consider queue workers for async processing. |
| Security | A1/A3 certificates and XML payloads must be protected (e.g., from tampering). | Use Laravel’s encryption for certificates; validate XML against SEFAZ schemas. |
| Testing | Mocking SEFAZ responses is complex (real API calls needed for full testing). | Use VCR recordings (e.g., vcrphp) for deterministic tests. |
NFeService).nfephp/nfe-queue) for async SEFAZ communication.NFeAuthorized, NFeDenied).nfes):
Schema::create('nfes', function (Blueprint $table) {
$table->id();
$table->string('nfe_number');
$table->text('xml_payload');
$table->json('sefa_response');
$table->enum('status', ['pending', 'authorized', 'denied', 'cancelled']);
$table->timestamps();
});
POST /nfes (generate NF-e)GET /nfes/{id} (retrieve status)POST /nfes/{id}/cancel (cancel NF-e)sped-nfe covers all required SEFAZ interactions (e.g., CT-e, MDF-e).SimpleXMLElement deprecations).ext-dom, ext-soap, and ext-xml PHP extensions are enabled.spatie/array-to-xml).composer require nfephp-org/sped-nfe..env).NFeService facade wrapping the package’s NFe class.laravel-logger).nfeProc timeouts).How can I help you explore Laravel packages today?