bambamboole / tools
Tools: tax rates, VAT id validation and more.
Requires
- php: ^8.4
- ext-dom: *
- ext-soap: *
- brick/money: ^0.14.1
- illuminate/cache: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- ricorocks-digital-agency/soap: ^4.0
Requires (Dev)
- laravel/pint: ^1.16
- pestphp/pest: ^5.0
- phpstan/phpstan: ^2.1
Suggests
- laravel/framework: Auto-discovers the ToolsServiceProvider to resolve the tools from the container
This package is auto-updated.
Last update: 2026-08-08 12:57:39 UTC
README
A small toolbox for European commerce plumbing:
- Tax rates from the EU TEDB database (SOAP)
- VAT id validation via VIES (SOAP)
- Exchange rates from the ECB reference rates, including full history
- Currency conversion built on brick/money
All amounts and rates are Brick\Math\BigDecimal — no floats.
Requirements
- PHP 8.4+ with
ext-soapandext-dom
Installation
composer require bambamboole/tools
Usage
use Bambamboole\Tools\ToolManager; $tools = new ToolManager(); // VAT rates for a country (TEDB) $rates = $tools->taxRates()->getTaxRates('DE'); // Validate a VAT id (VIES) $result = $tools->vatId()->validate('DE123456789'); $result->valid; // bool // ECB euro reference rates, latest or historical $day = $tools->exchangeRates()->getExchangeRates(); $day->rate('USD'); // BigDecimal $day = $tools->exchangeRates()->getExchangeRates(new DateTimeImmutable('2020-03-13')); // Convert money, incl. cross rates via EUR use Brick\Math\RoundingMode; use Brick\Money\Money; $converter = $tools->currencyConverter(); $converter->convert(Money::of(100, 'USD'), 'GBP', roundingMode: RoundingMode::HalfEven);
Caching
The tax rate and exchange rate clients accept any Illuminate\Contracts\Cache\Repository
(usable standalone, no Laravel app required). Fetched feeds are cached in bulk, historical
days indefinitely, today's rates for 15 minutes. When the cache store supports atomic locks
(Redis, Valkey, memcached, database), concurrent misses are collapsed into a single fetch.
use Illuminate\Cache\ArrayStore; use Illuminate\Cache\Repository; $cache = new Repository(new ArrayStore()); $rates = $tools->exchangeRates($cache)->getExchangeRates();
Laravel
The service provider is auto-discovered and wires everything against your default cache store — inject and go:
public function __construct( private readonly Bambamboole\Tools\ExchangeRates\ExchangeRatesClient $exchangeRates, private readonly Brick\Money\CurrencyConverter $converter, ) {}
Or use the auto-discovered Tools facade:
use Tools; Tools::taxRates()->getTaxRates('DE'); Tools::vatId()->validate('DE123456789'); Tools::exchangeRates()->getExchangeRates(); Tools::currencyConverter()->convert(...);
Testing
composer test
License
MIT