Download the PHP package breeze_converter/currency without Composer

On this page you can find all versions of the php package breeze_converter/currency. 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 currency

Currency Converter Breeze

This currency conversion library is a simple, chainable PHP library that provides easy access to real-time currency conversion using exchange rates fetched from an external API (https://api.exchangerate-api.com). It allows you to set a base currency, specify target currencies, and convert amounts with just a few lines of code. This library handles caching exchange rates in the session for efficiency and provides both array and JSON output formats for flexibility.

Key Features:

Installation

You can install the library via Composer. Run the following command in your terminal:

Make sure Composer is installed on your system. For more information on Composer, visit the Composer Documentation.

Getting Started

Follow the steps below to start using the Converter library in your PHP project:

1. Basic Usage Example

Here's a quick example to convert an amount from one currency to multiple target currencies:

2. Session Handling

Ensure that PHP sessions are enabled as the library uses session-based caching for exchange rates.

Responses

The Converter library returns data in two formats: Array or JSON, depending on the output type you specify when calling the run() method.

Successful Response

If the conversion is successful, you'll receive a response with the status "success" and the converted values.

Example (Array Format):

Response:

Example (JSON Format):

Response

Error Response

If an error occurs (e.g., invalid currency code, API failure), the library will return a response with the status "error" and an error message.

Example:

Response:

[!NOTE] With just a few lines of code, you can convert amounts between multiple currencies, making this library ideal for e-commerce platforms, financial applications, and any service that requires currency conversion!

Default Settings

The library provides a set of default values that can be used for ease of setup, while also allowing flexibility to override these settings using chainable methods.

  1. Base Currency

    • Default: 'USD'
    • By default, the library uses the US Dollar (USD) as the base currency for conversion. This means that unless specified otherwise, all conversions will be calculated from USD.
    • How to Overwrite: Use the baseCurrency() method to specify a different base currency. For example, if you want to use Canadian Dollars (CAD) as the base currency:
  2. Default Amount

    • Default: 1
    • If no specific amount is provided, the library defaults to converting 1 unit of the base currency to the target currencies. This is useful for quick rate checks.
    • How to Overwrite: You can set a custom amount using the defaultAmount() method. For instance, to convert 100 CAD:
  3. Cookie Expiry (Session Cache)
    • Default: 300 seconds (5 minutes)
    • The library caches exchange rates in the session for 5 minutes by default. This reduces the number of API requests, improving efficiency. Cached rates will be used within the specified expiry time, after which a new API request will be made.
    • How to Overwrite: You can customize the caching time using the expiry() method. For example, to keep the cached rates for 5 minutes:

Example Usage with Custom Default Settings:

In this example:

#

Contributing

Contributions are welcomed to this library Whether you're fixing bugs, adding new features, improving documentation, or suggesting enhancements, your contributions are valuable.

Feel free to submit pull requests or open issues if you encounter any problems or have suggestions for improvement.

Dependencies

This project does not rely on any external dependencies, making it easy to set up and use.

License

This project is licensed under the MIT License.


All versions of currency with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 breeze_converter/currency contains the following files

Loading the files please wait ....