flexmind-software / currency-rate
Library download currency rate and save in database, It's designed to be extended by any available data source.
Fund package maintenance!
flexmind-software
Requires
- php: ^7.4
- ext-json: *
- ext-libxml: *
- ext-simplexml: *
- ext-soap: *
- illuminate/contracts: ^8.37
- illuminate/support: ^8.37
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- brianium/paratest: ^6.2
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^6.15
- phpunit/phpunit: ^9.3
- vimeo/psalm: ^4.8
- dev-main
- 0.1.1
- 0.1.0
- 0.0.11
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- dev-develop
- dev-feature/update-readme-with-usage-instructions
- dev-feature/add-logger-to-all-drivers-yqe5kc
- dev-feature/add-logger-to-all-drivers
- dev-feature/extend-httpfetcher-with-retry-and-backoff
- dev-feature/add-unit-tests-for-httpfetcher
- dev-feature/validate-driver-classes-in-currencyrateserviceprovider
- dev-feature/add-log_channel-configuration-and-tests
- dev-feature/add-currency-option-to-downloadcommand
- dev-feature/add-unitedstatesdriver-implementation
- dev-feature/add-semaphore-mechanism-to-queuedownload
- dev-feature/add-spanish-language-support
- dev-feature/add-currency-rate-api-with-tests
- dev-feature/add-auditlog-model-and-migration
- dev-feature/expand-cachefactory-to-support-redis
- dev-feature/iran
This package is auto-updated.
Last update: 2025-08-27 14:13:55 UTC
README
Installation
You can install the package via composer:
composer require flexmind-software/currency-rate
You can publish and run the migrations with:
php artisan vendor:publish --provider="FlexMindSoftware\CurrencyRate\CurrencyRateProvider" --tag="currency-rate-migrations" php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="FlexMindSoftware\CurrencyRate\CurrencyRateProvider" --tag="currency-rate-config"
This is the contents of the published config file:
return [ 'driver' => env('FLEXMIND_CURRENCY_RATE_DRIVER', 'european-central-bank'), 'drivers' => [ 'albania', 'armenia', 'australia', 'azerbaijan', 'bceao', 'belarus', 'bosnia-and-herzegovina', 'botswana', 'bulgaria', 'canada', 'china', 'croatia', 'czech-republic', 'denmark', 'england', 'european-central-bank', 'fiji', 'georgia', 'hungary', 'iceland', 'israel', 'macedonia', 'moldavia', 'norway', 'poland', 'romania', 'russia', 'serbia', 'sweden', 'switzerland', 'turkey', 'ukraine', ], 'table-name' => env('FLEXMIND_CURRENCY_RATE_TABLENAME', 'currency_rates'), 'cache-ttl' => env('FLEXMIND_CURRENCY_RATE_CACHE_TTL', 3600), ];
The drivers
array defines which currency rate providers are available when running
the command with --driver=all
. Add or remove entries from this list to customise
the drivers used in your application. See config/currency-rate.php for additional configuration options, including the cache TTL for HTTP requests.
Available Drivers
Country / Source | Driver |
---|---|
Albania | albania |
Armenia | armenia |
Australia | australia |
Azerbaijan | azerbaijan |
BCEAO | bceao |
Belarus | belarus |
Bosnia and Herzegovina | bosnia-and-herzegovina |
Botswana | botswana |
Bulgaria | bulgaria |
Canada | canada |
China | china |
Croatia | croatia |
Czech Republic | czech-republic |
Denmark | denmark |
England | england |
European Central Bank | european-central-bank |
Fiji | fiji |
Georgia | georgia |
Hungary | hungary |
Iceland | iceland |
Israel | israel |
Macedonia | macedonia |
Moldavia | moldavia |
Norway | norway |
Poland | poland |
Romania | romania |
Russia | russia |
Serbia | serbia |
Sweden | sweden |
Switzerland | switzerland |
Turkey | turkey |
Ukraine | ukraine |
Usage
php artisan flexmind:currency-rate [options] [--] [<date>] Arguments: date Date to download currency rate, if empty is today Options: --queue[=QUEUE] Queue name, if set "none" cmd run without add job to queue [default: "none"] --driver[=DRIVER] Driver to download rate [default: "all"]
Events
The CurrencyRate::saveIn
method dispatches a CurrencyRateSaved
event once rates are persisted. Consumers may listen for this event to trigger downstream actions:
use FlexMindSoftware\CurrencyRate\Events\CurrencyRateSaved; use Illuminate\Support\Facades\Event; Event::listen(CurrencyRateSaved::class, function (CurrencyRateSaved $event) { // $event->rates contains the saved records }); ### Examples Run for today's rates using all configured drivers: ```bash php artisan flexmind:currency-rate
Fetch rates for a specific date:
php artisan flexmind:currency-rate 2023-09-15
Use a specific driver:
php artisan flexmind:currency-rate --driver=canada
Dispatch the job to a queue:
php artisan flexmind:currency-rate --queue=default
Execute immediately without queueing:
php artisan flexmind:currency-rate --queue=none
Testing
composer test
Sources
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Adding new locales
Translations for driver descriptions live in resources/langs/{locale}/description.php
.
To contribute a new locale:
- Create a new directory for the locale under
resources/langs
(for examplees
for Spanish). - Copy
resources/langs/en/description.php
into that directory and translate the strings. - Submit a pull request with the new translation file.
Credits
License
The MIT License (MIT). Please see License File for more information.