matav5/vies-sdk
Composer 安装命令:
composer require matav5/vies-sdk
包简介
PHP SDK for the EU VIES (VAT Information Exchange System) REST API
README 文档
README
PHP SDK for the EU VIES (VAT Information Exchange System) REST API.
Validate EU VAT numbers and check the availability of member states via a clean, PSR-18 compatible HTTP client.
Requirements
- PHP 8.1+
- A PSR-18 HTTP client (e.g.
symfony/http-client) - A PSR-17 request & stream factory (e.g.
nyholm/psr7)
Installation
composer require matav5/vies-sdk
You also need a PSR-18 client and PSR-17 factories. The recommended combination:
composer require symfony/http-client nyholm/psr7
Usage
Setup
use Matav5\ViesSdk\ViesClient; use Nyholm\Psr7\Factory\Psr17Factory; use Symfony\Component\HttpClient\Psr18Client; $psr17 = new Psr17Factory(); $http = new Psr18Client(null, $psr17, $psr17); $vies = new ViesClient($http, $http, $http);
Psr18Client implements PSR-18, PSR-17 RequestFactory and PSR-17 StreamFactory simultaneously, which is why it is passed three times.
Validate a VAT number
use Matav5\ViesSdk\Request\CheckVatRequest; $response = $vies->vat()->check(new CheckVatRequest('CZ', '27082440')); $response->isValid(); // true $response->getCountryCode(); // 'CZ' $response->getVatNumber(); // '27082440' $response->getName(); // 'Alza.cz a.s.' $response->getAddress(); // 'Jankovcova 1522/53 ...' $response->getRequestDate(); // '2024-01-01T00:00:00Z'
Approximate trader matching
Pass optional trader fields to verify company details against the VIES registry. The API returns a MatchStatus for each field if the member state supports approximate matching.
use Matav5\ViesSdk\Enum\MatchStatus; use Matav5\ViesSdk\Request\CheckVatRequest; $request = new CheckVatRequest( countryCode: 'DE', vatNumber: '123456789', traderName: 'Example GmbH', traderCity: 'Berlin', ); $response = $vies->vat()->check($request); $response->getTraderNameMatch(); // MatchStatus::VALID | INVALID | NOT_PROCESSED | null $response->getTraderCityMatch();
NOT_PROCESSED means the member state does not support approximate matching for that field.
To also receive a requestIdentifier, provide your own VAT number as the requester:
$request = new CheckVatRequest( countryCode: 'DE', vatNumber: '123456789', requesterMemberStateCode: 'CZ', requesterNumber: 'CZ27082440', ); $response->getRequestIdentifier(); // 'WAPPws...'
Test endpoint
The VIES API provides a test endpoint that works without a real VAT number:
// vatNumber 100 → valid, 200 → invalid (documented test values) $response = $vies->vat()->checkTest(new CheckVatRequest('CZ', '100')); $response->isValid(); // true
Member state availability
$status = $vies->status()->check(); $status->isVowAvailable(); // true $status->getCountries(); // array<CountryStatus> foreach ($status->getCountries() as $country) { echo $country->getCountryCode(); // 'CZ' echo $country->getAvailability(); // 'Available' | 'Unavailable' | 'Monitoring Disabled' }
Error handling
use Matav5\ViesSdk\Exception\ApiException; use Matav5\ViesSdk\Exception\ViesSdkException; try { $response = $vies->vat()->check(new CheckVatRequest('CZ', '')); } catch (ApiException $e) { // HTTP error response from the VIES API $e->getStatusCode(); // 400 $e->getErrorCodes(); // ['VOW-ERR-11'] $e->getResponse(); // PSR-7 ResponseInterface } catch (ViesSdkException $e) { // Network error or invalid JSON response }
ApiException extends ViesSdkException, so you can catch all SDK errors with a single catch (ViesSdkException $e).
Custom configuration
use Matav5\ViesSdk\Config; use Matav5\ViesSdk\ViesClient; $config = new Config( baseUrl: 'https://ec.europa.eu/taxation_customs/vies/rest-api', timeout: 10, ); $vies = new ViesClient($http, $http, $http, $config);
Running tests
# Unit tests only composer test # Integration tests (calls the real VIES API) composer test:integration # All tests composer test:all
License
MIT
matav5/vies-sdk 适用场景与选型建议
matav5/vies-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 118 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sdk」 「vat」 「tax」 「vies」 「eu」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 matav5/vies-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 matav5/vies-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 matav5/vies-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A VAT number check (Web Service) Plugin for CakePHP
API client for validating Tax Identification Number.
Validate the format of EU vat numbers.
Module allowing creation of tax rates and categories in the CMS via SiteConfig
PHP VAT checker based on the European Commission web service
Australian Tax Rules for OroCommerce
统计信息
- 总下载量: 118
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-20