1. Go to this page and download the library: Download akaunting/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/ */
akaunting / money example snippets
use Akaunting\Money\Currency;
use Akaunting\Money\Money;
echo Money::USD(500); // '$5.00' unconverted
echo new Money(500, new Currency('USD')); // '$5.00' unconverted
echo Money::USD(500, true); // '$500.00' converted
echo new Money(500, new Currency('USD'), true); // '$500.00' converted
use Akaunting\Money\Currency;
use Akaunting\Money\Money;
Money::macro('zero', fn (?string $currency = null) => new Money(0, new Currency($currency ?? 'GBP')));
$money = Money::zero();
use Akaunting\Money\Money;
class CustomMoney
{
public function absolute(): Money
{
return $this->isPositive() ? $this : $this->multiply(-1);
}
public static function zero(?string $currency = null): Money
{
return new Money(0, new Currency($currency ?? 'GBP'));
}
}
Money::mixin(new CustomMoney);
$money = Money::USD(1000)->multiply(-1);
$absolute = $money->absolute();
// Static methods via mixins are supported too:
$money = Money::zero();
bash
php artisan vendor:publish --tag=money
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.