1. Go to this page and download the library: Download leancaptain/money 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/ */
leancaptain / money example snippets
use LeanCaptain\Money\Currency;
use LeanCaptain\Money\Money;
$money = Money::of('1250.50', Currency::BDT);
$money->minorAmount(); // 125050
$money->toDecimal(); // "1250.50"
$money->currency(); // Currency::BDT
use LeanCaptain\Money\Contracts\CurrencyContract;
enum AppCurrency: string implements CurrencyContract
{
case BDT = 'BDT';
case USD = 'USD';
public function code(): string
{
return $this->value;
}
public function minorUnit(): int
{
return 2;
}
}
use LeanCaptain\Money\Currency;
use LeanCaptain\Money\MoneyFactory;
use LeanCaptain\Money\RoundingMode;
$factory = new MoneyFactory(
Currency::BDT,
RoundingMode::HALF_UP,
);
$money = $factory->of('100.50');