Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bigoen/currency-api-bundle
https://github.com/bigoen/currency-api-bundle
Last synced: 2 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/bigoen/currency-api-bundle
- Owner: bigoen
- License: mit
- Created: 2024-10-15T13:57:01.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2024-10-21T18:58:15.000Z (24 days ago)
- Last Synced: 2024-10-22T04:26:07.276Z (24 days ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Currency Api Bundle
This Symfony bundle provides integration with the Currency Beacon API, allowing you to fetch and manage currency data within your Symfony application.
## Installation
1. Install the bundle using Composer:
```bash
composer require bigoen/currency-api-bundle
```2. Enable the bundle in your `config/bundles.php` file:
```php
return [
// ...
Bigoen\CurrencyApiBundle\BigoenCurrencyApiBundle::class => ['all' => true],
];
```## Configuration
Add the following environment variables to your `.env` file:
```dotenv
###> bigoen/currency-api-bundle ###
CURRENCY_BEACON_API_KEY=your_api_key_here
###< bigoen/currency-api-bundle ###
```## Usage
To use the Currency API service, you can inject it into your services or use it manually:
## Commands
This bundle provides commands to manage currency data:
- To update currencies, use:
```bash
php bin/console exchange-rate:currency-beacon:currency-update
```- To fetch the latest or historical daily exchange rates, use:
```bash
php bin/console exchange-rate:currency-beacon:daily-update
```Alternatively, you can use the `CurrencyBeaconService` directly in your code:
- To update currencies manually, use the `updateCurrencies` method:
```php
$currencyBeaconService->updateCurrencies();
```- To update daily exchange rates manually, use the `updateDailyExchangeRates` method:
```php
$currencyBeaconService->updateDailyExchangeRates();
```To query daily exchange rates by date and currency, you can use the `DailyExchangeRateRepository`:
- Example query:
```php
$repository = $entityManager->getRepository(DailyExchangeRate::class);
$exchangeRate = $repository->findOneBy(['date' => $date, 'currency' => $currency]);
$amount = $repository->convert('TRY', 'EUR', Carbon::now(), 500);
```## License
This bundle is released under the MIT License. See the bundled `LICENSE` file for details.