|
| 1 | +# CurrencyAPI Client for Peso |
| 2 | + |
| 3 | +[![Packagist]][Packagist Link] |
| 4 | +[![PHP]][Packagist Link] |
| 5 | +[![License]][License Link] |
| 6 | +[![GitHub Actions]][GitHub Actions Link] |
| 7 | +[![Codecov]][Codecov Link] |
| 8 | + |
| 9 | +[Packagist]: https://img.shields.io/packagist/v/peso/currencyapi-service.svg?style=flat-square |
| 10 | +[PHP]: https://img.shields.io/packagist/php-v/peso/currencyapi-service.svg?style=flat-square |
| 11 | +[License]: https://img.shields.io/packagist/l/peso/currencyapi-service.svg?style=flat-square |
| 12 | +[GitHub Actions]: https://img.shields.io/github/actions/workflow/status/phpeso/currencyapi-service/ci.yml?style=flat-square |
| 13 | +[Codecov]: https://img.shields.io/codecov/c/gh/phpeso/currencyapi-service?style=flat-square |
| 14 | + |
| 15 | +[Packagist Link]: https://packagist.org/packages/peso/currencyapi-service |
| 16 | +[GitHub Actions Link]: https://github.com/phpeso/currencyapi-service/actions |
| 17 | +[Codecov Link]: https://codecov.io/gh/phpeso/currencyapi-service |
| 18 | +[License Link]: LICENSE.md |
| 19 | + |
| 20 | +This is an exchange data provider for Peso that retrieves data from |
| 21 | +[CurrencyAPI](https://currencyapi.com/). |
| 22 | + |
| 23 | +## Installation |
| 24 | + |
| 25 | +```bash |
| 26 | +composer require peso/currencyapi-service |
| 27 | +``` |
| 28 | + |
| 29 | +Install the service with all recommended dependencies: |
| 30 | + |
| 31 | +```bash |
| 32 | +composer install peso/currencyapi-service php-http/discovery guzzlehttp/guzzle symfony/cache |
| 33 | +``` |
| 34 | + |
| 35 | +## Example |
| 36 | + |
| 37 | +```php |
| 38 | +<?php |
| 39 | + |
| 40 | +use Peso\Peso\CurrencyConverter; |
| 41 | +use Peso\Services\CurrencyApiService; |
| 42 | +use Peso\Services\CurrencyApiService\Subscription; |
| 43 | +use Symfony\Component\Cache\Adapter\FilesystemAdapter; |
| 44 | +use Symfony\Component\Cache\Psr16Cache; |
| 45 | + |
| 46 | +require __DIR__ . '/../vendor/autoload.php'; |
| 47 | + |
| 48 | +$cache = new Psr16Cache(new FilesystemAdapter(directory: __DIR__ . '/cache')); |
| 49 | +$service = new CurrencyApiService('cur_live_...', Subscription::Free, cache: $cache); |
| 50 | +$converter = new CurrencyConverter($service); |
| 51 | + |
| 52 | +// 10777.50 as of 2025-07-30 |
| 53 | +echo $converter->convert('12500', 'USD', 'EUR', 2), PHP_EOL; |
| 54 | +``` |
| 55 | + |
| 56 | +## Documentation |
| 57 | + |
| 58 | +Read the full documentation here: <https://phpeso.org/v1.x/services/currencyapi.html> |
| 59 | + |
| 60 | +## Support |
| 61 | + |
| 62 | +Please file issues on our main repo at GitHub: <https://github.com/phpeso/currencyapi-service/issues> |
| 63 | + |
| 64 | +## License |
| 65 | + |
| 66 | +The library is available as open source under the terms of the [MIT License][License Link]. |
0 commit comments