PHP code example of mgcodeur / laravel-currency-converter
1. Go to this page and download the library: Download mgcodeur/laravel-currency-converter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mgcodeur / laravel-currency-converter example snippets
// convert 10 USD to MGA
$convertedAmount = CurrencyConverter::convert(10)
->from('USD')
->to('MGA')
->get();
dd($convertedAmount);
use Mgcodeur\CurrencyConverter\Facades\CurrencyConverter;
// convert 5 EUR to all currencies
$convertedAmount = CurrencyConverter::convert(5)
->from('EUR')
->get();
dd($convertedAmount);
// convert 10 USD to EUR and format the result
$convertedAmount = CurrencyConverter::convert(10)
->from('USD')
->to('EUR') // The 'to' method specifies the target currency. If you want to convert between all currencies, you can omit this method.
->format();
dd($convertedAmount);
return [
'currency' => [
'format' => [
'decimals' => 2, // Number of decimal places
'decimal_separator' => ',', // Decimal separator: used to separate the integer part from the fractional part (e.g., 1,99)
'thousand_separator' => '.', // Thousand separator: used to separate groups of thousands in large numbers (e.g., 1.000 for one thousand)
]
],
];
bash
php artisan currency-converter:install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.