fdisotto/partita-iva
Laravel/PHP package to validate EU VAT numbers via the EU VIES service (checkVatService). Performs a remote lookup against the official EC endpoint to confirm whether a VAT number exists across EU Member States.
Use Case Alignment:
The updated package (fdisotto/partita-iva@3.0.0) now includes real-time VAT validation via the European Commission’s VIES API, expanding its scope from Italian-only (Partita IVA) validation to EU-wide VAT verification. This makes it a stronger fit for:
Stateless vs. Stateful:
Domain-Specific Strengths:
PHP/Laravel Compatibility:
https://ec.europa.eu/taxation_customs/vies/).3.0.0 release likely deprecates the old validateVatNumber() method in favor of a new validateWithVIES() or similar.Error Handling:
Illuminate\Support\Facades\Http or Guzzle for retry logic.Performance:
VIES API Reliability:
Data Privacy/Compliance:
Breaking Changes:
Validator::checkVat($vat) → Validator::validateWithVIES($vat)).Testing Complexity:
Business Requirements:
API Strategy:
Cost/Infrastructure:
Maintenance:
Alternatives:
viestax/vies (PHP library for VIES).spatie/laravel-vat (Laravel package with VIES support).Laravel Ecosystem:
namespace App\Services;
class VatValidationService
{
public function validate(string $vatNumber, bool $useVIES = true): bool
{
// Local validation (always fast)
$localValid = $this->validateLocally($vatNumber);
if (!$useVIES || !$localValid) {
return $localValid;
}
// VIES validation (slow, optional)
return $this->validateWithVIES($vatNumber);
}
protected function validateLocally(string $vatNumber): bool
{
$validator = new \Fdisotto\PartitaIva\Validator();
return $validator->validate($vatNumber);
}
protected function validateWithVIES(string $vatNumber): bool
{
$http = new \GuzzleHttp\Client();
$response = $http->post('https://ec.europa.eu/taxation_customs/vies/checkVatService', [
'form_params' => [
'vatNumber' => $vatNumber,
'countryCode' => $this->extractCountryCode($vatNumber),
],
]);
$xml = simplexml_load_string($response->getBody());
return (string)$xml->valid === 'true';
}
}
use App\Rules\ValidVat;
public function rules()
{
return [
'vat_number' => ['required', new ValidVat],
];
}
vat:validate command for bulk checks (with queuing):
Artisan::command('vat:validate', function () {
$vats = File::lines('storage/vats.txt');
foreach ($vats as $vat) {
VatValidationJob::dispatch($vat)->onQueue('vat-validation');
}
});
HTTP Client:
Http::post) or Guzzle for VIES requests.Http::timeout(5)->retry(3, 100)->post('...');
Testing:
3.0.0 package against:
How can I help you explore Laravel packages today?