Download the PHP package makeabledk/laravel-currencies without Composer

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

Laravel Currencies

Latest Version on Packagist Build Status StyleCI

This package provides a convenient and powerful way of interacting with currencies and amounts in Laravel.

Install

You can install this package via composer:

On Laravel versions < 5.5, you must include the service provider in you config/app.php:

After installation you mus publish and run migrations to create the currencies table

Setup

Recommended: Seed currencies

This package provides a eloquent 'Currency' model out of the box that fetches available currencies from your database.

Often you would want to seed these currencies from your code in order to normalize them across environments. This can easily be achieved with the Laravel Production Seeding package.

Create the following seeder and let it run on each deployment:

Now your database table should look something like this:

id code exchange_rate
1 EUR 100.00
2 DKK 750.00

Tip: Consider using [https://github.com/dwightwatson/rememberable]() to cache currencies and throttle database queries.

Tip: If you don't want to hardcode exchange rates, create a console-command that fetches and updates from an external service, and ommit the field from the seeder.

Register base currency (required)

The amount object requires a base currency that it uses to convert between currencies.

The exchange rates given for your currencies must all relate to the base currency.

Define it in your AppServiceProvider@boot:

Register default currency (optional)

Additionally you have the option to define a default currency if this is not the same as your base-currency.

You may want to have a global currency such as USD or EUR for your base-currency to perform conversions, meanwhile your application defaults to display a local currency.

This can be achieved by defining a default-currency in your AppServiceProvider@boot as well:

Now when instantiating an amount without an explicit Currency it will default to 'DKK':

Example usages

Quickly create an amount

Convert between currencies

Perform simple calculations - even between currencies!

Imagine you have a Product eloquent model with a @getPriceAttribute() accessor that returns an Amount object, you can even do this:

Use the fluent modifiers for easy manipulation

Easily export as an array, and re-instantiate if needed. Great for serving client API*.

*Note it implements illuminate/support Arrayable contract, so it automatically casts to an array for eloquent models.

Change log

Please see CHANGELOG for more information what has changed recently.

Testing

You can run the tests with:

Contributing

We are happy to receive pull requests for additional functionality. Please see CONTRIBUTING for details.

Credits

License

Attribution-ShareAlike 4.0 International. Please see License File for more information.


All versions of laravel-currencies with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/container Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.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 makeabledk/laravel-currencies contains the following files

Loading the files please wait ....