bambamboole/tools
Tools: tax rates, VAT id validation and more.
3,091
| Install | |
|---|---|
composer require bambamboole/tools |
|
| Latest Version: | 0.1.0 |
| PHP: | ^8.4 |
| License: | MIT |
| Last Updated: | Aug 8, 2026 |
| Links: | GitHub · Packagist |
Maintainer: bambamboole
bambamboole/tools
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
Related Packages
davestewart/sketchpad
An innovative front-end environment for interactive Laravel development
12,918
295