- Can I use ddeboer/vatin-bundle in Laravel even though it’s a Symfony bundle?
- Yes, but you’ll need to adapt it. The bundle relies on Symfony’s validator and service container, so you can either wrap it in a Laravel service layer or use a Symfony bridge like `spatie/laravel-symfony-support`. Laravel 9+ works best due to Symfony 8 compatibility.
- What Laravel versions support ddeboer/vatin-bundle?
- Laravel 9 and 10 are officially recommended due to Symfony 8 alignment. Laravel 8 may work with manual dependency pinning (e.g., Symfony 6.x), but PHP 8.1+ is required. Test thoroughly for version conflicts.
- How do I integrate this bundle into Laravel’s validation system?
- Use the `Vatin` constraint in Form Requests or model properties (e.g., `#[Vatin]`). For Laravel’s validator, bind the Symfony validator service to Laravel’s container or create a custom rule extending `Vatin`. Example: `Validator::extend('vatin', fn ($attr, $value, $params) => $validator->isValid($value));`
- What happens if the VIES SOAP service is down during VAT existence checks?
- The bundle throws a `ValidatorException`. Handle it gracefully with fallbacks: cache responses locally (e.g., Redis), use offline validation, or notify admins. Avoid critical-path failures by prioritizing format validation over API checks.
- Are there performance concerns with real-time VIES API calls?
- Yes. VIES API calls are slow (~1–3 seconds) and unreliable. Cache responses aggressively (e.g., 24-hour TTL) and avoid calling it on every request. For high-traffic apps, batch checks or use a queue system like Laravel Queues.
- Can I validate non-EU VAT numbers (e.g., US sales tax, Canadian GST) with this package?
- No. This bundle is EU-focused. For non-EU VAT, use the `formatOnly: true` option to validate structure only, then implement custom logic for other tax systems. Consider libraries like `league/tax-vat` for broader support.
- How do I install ddeboer/vatin-bundle in Laravel without Symfony?
- Run `composer require ddeboer/vatin-bundle`. Manually register the bundle’s services in Laravel’s container by binding `ddeboer_vatin.vatin_validator` and `ddeboer_vatin.vies.client` to their Symfony equivalents. Use `app()->make()` or Laravel’s service provider.
- What’s the difference between `checkExistence: false` and `true` in the Vatin constraint?
- `checkExistence: false` validates VAT format only (fast, no API calls). `true` adds a VIES API check (slow, unreliable). Use `false` for offline systems or when API failures aren’t critical. Example: `#[Vatin(checkExistence: false)]`
- Are there alternatives to ddeboer/vatin-bundle for Laravel?
- Yes. For format validation, use `league/tax-vat` (pure PHP, no API). For VIES checks, consider `mikehaertl/php-vies` (Laravel-specific wrapper). If you need both, this bundle is the most feature-complete but requires Symfony integration.
- How do I test VAT validation in Laravel’s unit tests?
- Mock the VIES client service to return predictable responses. Use Laravel’s `partialMock` or `createMock` to simulate API failures or valid/invalid VATs. Example: `Mockery::mock('ddeboer_vatin.vies.client')->shouldReceive('checkVat')->andReturn(new CheckVatResponse(true));`