- Can I use this package in Laravel without Symfony dependencies?
- Yes, the core DTOs (e.g., `ComprobanteRequestDto`) are decoupled from Symfony and work standalone. Only the optional `ContractValidator`/`ContractNormalizer` services require Symfony components like `symfony/options-resolver`. You can skip the bundle if avoiding Symfony.
- What Laravel versions support this package?
- The package requires PHP 8.5+ and Symfony 8.x, which aligns with Laravel 10+. For Laravel 9.x, you’d need to manually resolve Symfony version conflicts or upgrade. Test compatibility with `platform-check` before full adoption.
- Does this cover all Factura-X profiles (e.g., BASIC, COMMUNICATION) for Mexico’s CFDI?
- The package includes DTOs for core schemas (e.g., `ComprobanteRequestDto`) but lacks profile-specific validators (e.g., mandatory fields for `PERSONA_MORAL`). You’ll need custom logic or extensions like `heynemann/laravel-facturae` for full compliance.
- How do I validate a Factura-X payload before sending to the API?
- Use the DTOs to construct JSON payloads, then validate locally with `ContractValidator` (if using Symfony) or manually with Laravel’s `Validator`. Example: `$dto = new ComprobanteRequestDto($data); $validator->validate($dto)`. See `docs/examples/v1/` for JSON schemas.
- Will this package work with Laravel Queues for async invoice processing?
- The DTOs are queue-friendly, but the Symfony bundle’s services (e.g., `ContractNormalizer`) may not serialize well. For async workflows, use the DTOs directly in jobs and avoid bundle services, or mock Symfony dependencies with `illuminate/support`.
- Are there alternatives for Factura-X validation in Laravel without Symfony?
- Yes, consider `spatie/laravel-data` for structured DTOs or `heynemann/laravel-facturae` for CFDI-specific XML generation. For pure validation, Laravel’s built-in `Validator` or `laravel-validator` can handle JSON schemas manually.
- How do I handle Symfony dependency conflicts in my Laravel project?
- Run `composer why symfony/*` to audit conflicts. Resolve with explicit versions: `composer require symfony/options-resolver:^7.1 symfony/http-foundation:^7.1`. Avoid pulling in `symfony/console` or other heavy components unless needed.
- Can I generate PDFs/XML from these DTOs for invoice rendering?
- The package focuses on JSON payload validation, not rendering. For PDFs, integrate with `dompdf` or `spatie/pdf-to-html`. For XML (e.g., CFDI), use `heynemann/laravel-facturae` or manually transform DTOs to XML with `SimpleXMLElement`.
- What’s the maintenance roadmap for PHP 8.3/8.4 support?
- The package targets PHP 8.5+, so older versions (8.3/8.4) may not be supported. Check the GitHub repo for updates. If you need backward compatibility, fork the package or use a wrapper to abstract Symfony dependencies.
- How do I test this package in a Laravel project?
- Install via `composer require carloschininin/facturax-contracts`, then test DTOs with PHPUnit. For Symfony services, mock dependencies or use Laravel’s `MockApplication` to avoid container conflicts. Example: `php artisan test --filter TestFacturaxContracts`.