fsuuaas / finvoice
Modern Laravel package for generating PDF invoices
Requires
- php: ^8.1
- ext-iconv: *
- ext-mbstring: *
- brick/money: ^0.10.0
- dompdf/dompdf: ^2.0
- fpdf/fpdf: ^1.86
- illuminate/container: ^10.0
- illuminate/contracts: ^10.0
- illuminate/http: ^10.0
- illuminate/support: ^10.0
- laravel/framework: ^10.0
- league/commonmark: ^2.4
- spatie/laravel-package-tools: ^1.92
Requires (Dev)
- larastan/larastan: ^2.0
- laravel/pint: ^1.0
- pestphp/pest: ^2.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- rector/rector: ^0.19.0
README
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.