belghiti/vies-client
最新稳定版本:v0.1.1
Composer 安装命令:
composer require belghiti/vies-client
包简介
Core PSR-18 VIES (VoW) REST API client (Belghiti\Vies) with retry and DTOs.
README 文档
README
A lightweight, framework‑agnostic PSR‑18 client for the European Commission’s VIES (VAT Information Exchange System) REST API.
- DTOs for requests/responses (
CheckVatRequest,CheckVatResponse,StatusInformationResponse) - Retry decorator (exponential backoff)
- Contract test against the official Swagger (downloaded in CI)
- Non‑fatal smoke test of
GET /check-statusto the public VIES REST base
Requirements
- PHP 8.1+ (CI matrix covers 8.1 – 8.5)
- Any PSR‑18 HTTP client + PSR‑17 factories (e.g., Guzzle + Nyholm PSR‑7)
Installation
composer require belghiti/vies-client # (optional) choose a PSR-18 stack: composer require guzzlehttp/guzzle guzzlehttp/psr7 # Guzzle PSR-18 + PSR-7 # or composer require symfony/http-client nyholm/psr7 # Symfony Psr18Client + PSR-7
Quick start (Guzzle PSR‑18)
use Belghiti\Vies\Client\HttpViesClient; use Belghiti\Vies\Support\Adapter\GuzzlePsr18Client; use Belghiti\Vies\Dto\CheckVatRequest; use GuzzleHttp\Client as Guzzle; use GuzzleHttp\Psr7\HttpFactory; $psr18 = new GuzzlePsr18Client(new Guzzle()); $factory = new HttpFactory(); $client = new HttpViesClient( http: $psr18, requestFactory: $factory, streamFactory: $factory, baseUri: 'https://ec.europa.eu/taxation_customs/vies/rest-api' ); $res = $client->checkVatNumber(new CheckVatRequest('FR', '40303265045')); var_dump($res->valid);
API surface
interface ViesClientInterface { public function checkVatNumber(CheckVatRequest $request): CheckVatResponse; public function checkVatTestService(CheckVatRequest $request): CheckVatResponse; public function checkStatus(): StatusInformationResponse; }
CheckVatRequestmatches the public contract fields (countryCode,vatNumber, optionalrequester*& trader fields)checkStatus()returns overall VOW availability and per‑country availability entries
Retry & caching
- Wrap the core client with
Belghiti\Vies\Decorator\RetryingViesClientfor exponential backoff - Add your own cache decorator, or use the Laravel/Symfony packages for prebuilt caching
Quality
composer lint # PSR-12 via PHP_CodeSniffer composer stan # PHPStan (level max) vendor/bin/phpunit
License
MIT
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-23