bigoen/currency-api-bundle
最新稳定版本:v1.0.4
Composer 安装命令:
composer require bigoen/currency-api-bundle
包简介
Currency api bundle for Symfony project.
README 文档
README
This Symfony bundle provides integration with the Currency Beacon API, allowing you to fetch and manage currency data within your Symfony application.
Installation
- Install the bundle using Composer:
composer require bigoen/currency-api-bundle
- Enable the bundle in your
config/bundles.phpfile:
return [ // ... Bigoen\CurrencyApiBundle\BigoenCurrencyApiBundle::class => ['all' => true], ];
Configuration
Add the following environment variables to your .env file:
###> 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:
php bin/console exchange-rate:currency-beacon:currency-update
-
To fetch the latest or historical daily exchange rates, use:
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
updateCurrenciesmethod:$currencyBeaconService->updateCurrencies();
-
To update daily exchange rates manually, use the
updateDailyExchangeRatesmethod:$currencyBeaconService->updateDailyExchangeRates();
To query daily exchange rates by date and currency, you can use the DailyExchangeRateRepository:
- Example query:
$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.
统计信息
- 总下载量: 167
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2024-10-15