fsuuaas/finvoice

Modern Laravel package for generating PDF invoices

v2.6.11 2025-04-24 09:09 UTC

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads License

A modern Laravel package for generating beautiful PDF invoices. Built with PHP 8.1+ and Laravel 11/12 in mind.

Features

  • ๐ŸŽจ Beautiful, customizable invoice templates
  • ๐Ÿ› ๏ธ Modern, fluent API
  • ๐Ÿ’ฐ First-class support for money handling with Brick\Money
  • ๐ŸŒ Multi-currency support
  • ๐Ÿ“„ Multiple PDF renderers (Dompdf by default, FPDF as fallback)
  • ๐Ÿ”ง Highly configurable
  • ๐Ÿงช Well-tested with Pest
  • ๐Ÿ“ฆ Laravel-first with auto-discovery

Requirements

  • PHP 8.1 or higher
  • Laravel 11.0 or higher

Installation

You can install the package via composer:

composer require fsuuaas/finvoice

You can publish the config file with:

php artisan vendor:publish --provider="Fsuuaas\Finvoice\FinvoiceServiceProvider"

Usage

Basic Usage

use Fsuuaas\Finvoice\Facades\Finvoice;
use Fsuuaas\Finvoice\ValueObjects\Address;
use Fsuuaas\Finvoice\Enums\Currency;
use Brick\Money\Money;

$invoice = Finvoice::make()
    ->reference('INV-2024-001')
    ->seller(new Address(
        name: 'Acme Inc.',
        street: '123 Main St',
        city: 'New York',
        state: 'NY',
        postalCode: '10001',
        country: 'USA',
        phone: '+1 234 567 890',
        email: 'billing@acme.com',
        taxId: '123456789',
        registrationNumber: 'REG123'
    ))
    ->buyer(new Address(
        name: 'John Doe',
        street: '456 Oak Ave',
        city: 'Los Angeles',
        state: 'CA',
        postalCode: '90001',
        country: 'USA',
        email: 'john@example.com'
    ))
    ->currency(Currency::USD)
    ->item(
        description: 'MacBook Air M3',
        quantity: 2,
        unitPrice: Money::of(1199, 'USD'),
        discount: Money::of(100, 'USD')
    )
    ->notes('Thank you for your business')
    ->footerNote('Payment is due within 30 days');

// Generate PDF and return as string
$pdf = $invoice->render();

// Or download the PDF
return $invoice->download('invoice.pdf');

Configuration

You can configure various aspects of the invoice generation in the config/finvoice.php file:

return [
    'default_renderer' => 'dompdf',
    'renderers' => [
        'dompdf' => \Fsuuaas\Finvoice\Renderers\Pdf\DompdfRenderer::class,
        'fpdf' => \Fsuuaas\Finvoice\Renderers\Pdf\FpdfRenderer::class,
    ],
    'default_currency' => \Fsuuaas\Finvoice\Enums\Currency::USD,
    'default_due_days' => 30,
    'paper_size' => 'A4',
    'font' => 'DejaVu Sans',
    'logo_dimensions' => [
        'width' => 230,
        'height' => 130,
    ],
    'table' => [
        'background_opacity' => 0.06,
        'column_spacing' => 0.3,
    ],
    'margins' => [
        'left' => 15,
        'top' => 15,
        'right' => 15,
    ],
];

Customizing the Template

You can publish and customize the invoice template:

php artisan vendor:publish --provider="Fsuuaas\Finvoice\FinvoiceServiceProvider" --tag="views"

The template will be published to resources/views/vendor/finvoice/invoice.blade.php.

Testing

composer test

Static Analysis

composer analyse

Code Style

composer format

Changelog

Please see CHANGELOG.md for more information on what has changed recently.

Contributing

Please see CONTRIBUTING.md for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The GPL-2.0-or-later License. Please see License File for more information.