Download the PHP package elegantly/laravel-forex without Composer

On this page you can find all versions of the php package elegantly/laravel-forex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-forex

Laravel Forex

Latest Version on Packagist Total Downloads Tests Laravel Pint PHPStan

Laravel Forex is a simple and flexible package for retrieving the latest and historical foreign exchange rates in your Laravel application.

By default, it uses the free tier from exchangerate-api.com, but you can easily configure it to use any other Forex provider.


Contents


Features


Requirements


Installation

Install the package via Composer:

Publish the configuration file:


Configuration

The published configuration file lives at config/forex.php:

Environment Variables

Variable Description
EXCHANGE_RATE_API_TOKEN Your API token when using the paid exchangerate-api.com connector.
FOREX_CACHE_DRIVER The cache store used for Forex responses.
FOREX_RATE_LIMIT_DRIVER The cache store used for rate limiting.

Usage

All public methods are available through the Forex facade:

Latest Rates

Fetch the latest rates for a given base currency:

Historical Rates

Fetch historical rates for a specific date:

Converting Money

Convert a Money instance from one currency to another:

You can also convert against historical rates and override the rounding mode:

Validating Money

Use ValidMoney in Laravel validation rules to parse a money value and optionally enforce minimum and maximum amounts:

The value is parsed using the selected currency. If currency is omitted, the default currency from elegantly/laravel-money is used. To read the currency from another field in the validation data, pass its attribute name instead:

When min or max uses a different currency, the parsed amount is converted using the latest Forex rates before comparison. Bounds are inclusive; validation fails when the amount is below min or above max.

Refreshing Rates

By default, rates are cached according to your configuration. To bypass the cache and fetch fresh data:


Providers

ExchangeRate-Api.com

The package ships with two ready-to-use connectors for exchangerate-api.com:

To use the paid connector, update your config:

And add your token to .env:

Custom Client

Want to use a different provider? Implement the ForexClient interface:

Then set it as the active client:


Caching & Rate Limiting

The package uses Saloon's cache and rate-limit plugins to reduce API calls and avoid hitting provider limits.

Both features use the cache store configured in forex.php.


Testing

Run the test suite with:

Run the static analysis suite with:

Format the code with:


Changelog

See the CHANGELOG for details on recent updates.


Contributing

Contributions are welcome! Please read the CONTRIBUTING guide for details.


Security

If you discover any security-related issues, please refer to our security policy.


Credits


License

This package is open-source software licensed under the MIT license.


All versions of laravel-forex with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
elegantly/laravel-money Version ^4.0.0
illuminate/contracts Version ^13.0
saloonphp/cache-plugin Version ^3.0
saloonphp/laravel-plugin Version ^3.0||^4.0||^5.0
saloonphp/rate-limit-plugin Version ^2.0
saloonphp/saloon Version ^3.0||^4.0
spatie/laravel-package-tools Version ^1.14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package elegantly/laravel-forex contains the following files

Loading the files please wait ...