Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/devhammed/laravel-brick-money/llms.txt

Use this file to discover all available pages before exploring further.

Laravel Brick Money can be installed in any Laravel 10, 11, or 12 application using Composer. The package includes automatic service provider registration for a seamless installation experience.

Requirements

Before installing Laravel Brick Money, ensure your system meets these requirements:
1

PHP Version

PHP 8.2 or higher is required. Verify your PHP version:
php --version
2

Laravel Version

Laravel 10.x, 11.x, or 12.x. Check your Laravel version in composer.json:
"require": {
    "laravel/framework": "^10.0||^11.0||^12.0"
}
3

Optional Extensions

The ext-intl PHP extension is optional but recommended for locale-based formatting:
php -m | grep intl
Without ext-intl, you can still use the format() method, but formatLocale() will not be available.

Install via Composer

Install Laravel Brick Money using Composer:
composer require devhammed/laravel-brick-money
The package will automatically register its service provider and publish necessary assets thanks to Laravel’s package auto-discovery feature.

What Gets Installed

When you install the package, the following components are automatically registered:
The Devhammed\LaravelBrickMoney\Provider class is automatically registered and provides:
  • Configuration file registration
  • Blade directive registration (@money, @currency)
  • Blade component registration (<x-money>, <x-currency>)
  • Request macro registration (request()->money(), request()->currency())
  • Livewire synthesizer registration (if Livewire is installed)
Two global helper functions become available:
// Create Money instance
money(100, 'USD');        // Money::of(100, 'USD')
money(100, minor: true);  // Money::ofMinor(100)

// Create Currency instance
currency('USD');          // Currency::of('USD')
currency();               // Uses default from config
Model casts for storing money in databases:
  • AsIntegerMoney - Stores minor units (recommended)
  • AsDecimalMoney - Stores major units
  • AsCurrency - Stores currency codes
Custom validation rules:
  • MoneyRule - Validates monetary amounts
  • CurrencyRule - Validates currency codes

Verify Installation

Verify the package is installed correctly by running:
composer show devhammed/laravel-brick-money
You should see output similar to:
name     : devhammed/laravel-brick-money
descrip. : Laravel Brick Money Integration
versions : * 1.0.2

Testing the Installation

Create a test route to verify everything works:
1

Add Test Route

Add this to your routes/web.php:
routes/web.php
use Devhammed\LaravelBrickMoney\Money;

Route::get('/test-money', function () {
    $price = Money::of(99.99, 'USD');
    return $price->format(); // "$99.99"
});
2

Visit the Route

Start your development server and visit the route:
php artisan serve
Navigate to http://localhost:8000/test-money
3

Verify Output

You should see: $99.99
If you see this output, Laravel Brick Money is installed and working correctly!

Install Optional Dependencies

PHP Intl Extension

For locale-based formatting, install the Intl extension:
sudo apt-get install php8.2-intl
sudo systemctl restart php8.2-fpm
Verify installation:
use Devhammed\LaravelBrickMoney\Money;

$money = Money::of(1234.56, 'USD');
echo $money->formatLocale('en_US');  // "$1,234.56"
echo $money->formatLocale('de_DE');  // "1.234,56 $"

Livewire (Optional)

If you’re using Livewire, the package automatically registers synthesizers for Money and Currency objects:
composer require livewire/livewire
Now you can use Money objects directly in Livewire components:
use Livewire\Component;
use Devhammed\LaravelBrickMoney\Money;

class ProductPrice extends Component
{
    public Money $price;
    
    public function mount()
    {
        $this->price = Money::of(99.99, 'USD');
    }
    
    public function incrementPrice()
    {
        $this->price = $this->price->plus(10);
    }
}

Updating the Package

To update to the latest version:
composer update devhammed/laravel-brick-money
Always check the changelog before updating to see if there are any breaking changes.

Troubleshooting

If you see “Class ‘Devhammed\LaravelBrickMoney\Money’ not found”:
composer dump-autoload
php artisan clear-compiled
php artisan config:clear
If the service provider isn’t auto-registered, manually add it to config/app.php:
config/app.php
'providers' => [
    // Other providers...
    Devhammed\LaravelBrickMoney\Provider::class,
],
Ensure Composer’s autoload files are being loaded in your composer.json:
composer.json
"autoload": {
    "files": [
        "vendor/devhammed/laravel-brick-money/src/helpers.php"
    ]
}
Then run:
composer dump-autoload

Next Steps

Now that Laravel Brick Money is installed, learn how to configure it:

Configuration

Configure default currency, minor unit handling, and customize currency definitions.

Build docs developers (and LLMs) love