Download the PHP package finller/laravel-invoices without Composer

On this page you can find all versions of the php package finller/laravel-invoices. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-invoices

Everything You Need to Manage Invoices in Laravel

Latest Version on Packagist GitHub Tests Action Status Laravel Pint Total Downloads

Create, store, calculate, and render invoices, quotes, proformas, and credit notes in Laravel. The package supports multiple item-level discounts and taxes, serial numbers, PDF generation, mail attachments, polymorphic relations, Stripe Checkout imports, and GOBL export.

Amounts are denormalized: items and invoices hold their calculated amounts. Supply precomputed values from your application or payment provider, or call denormalize() to calculate missing amounts. Existing values are preserved unless you request recalculation.

There are two independent ways to use the package:

laravel-invoices

Interactive Demo

Try the interactive demo to explore the package.

Table of Contents

Requirements

The Stripe integration additionally requires stripe/stripe-php.

Installation

For Eloquent storage, publish and run the migrations:

Standalone PdfInvoice usage does not require migrations.

Configuration

Use config/invoices.php to configure your default seller, currency, rounding, serial numbers, and PDF appearance. See the configuration file for all settings and defaults.

Upgrading from v5

See the migration guide for breaking changes, database conversions, and examples for upgrading from v5 to v6.

The PdfInvoice Class

Build PDFs, Blade previews, and mail attachments from your own data, without database storage.

Full Example

Creating PDFs from Arrays

Use PdfInvoice::make() to build an invoice from nested arrays. Numeric amounts are in major units, using currency or invoices.default_currency (USD by default).

PDF Amounts and Denormalization

Each item holds its amounts, and the invoice holds their totals:

Item property Meaning Invoice total
unit_price Price of one unit before discounts and taxes. —
price_subtotal Line subtotal, normally unit_price × quantity. subtotal_amount
price_discount Sum of the line's discount amounts. discount_amount
price_tax Sum of the line's tax amounts. tax_amount
price Final line amount: price_subtotal − price_discount + price_tax. total_amount

Letting the Package Calculate Amounts

Call denormalize() to calculate line amounts and invoice totals before rendering:

Rendering does not calculate amounts automatically.

Using Precomputed Amounts

Supply line amounts and invoice totals directly when they have already been calculated:

You can mix precomputed and calculated amounts: denormalize() fills the gaps. To display discount and tax breakdowns, also supply the corresponding entries with their amounts.

Recalculating after Changes

After changing a quantity, unit price, discount, or tax percentage, request recalculation explicitly:

force: true recalculates line amounts and invoice totals. Percentage discounts and taxes are recalculated; fixed amounts remain inputs.

PDF Discounts and Taxes

Add percentage or fixed-amount discounts and taxes to each item:

The default template groups discount and tax breakdowns automatically. Use getDiscounts() and getTaxes() for these summaries in custom templates. Taxes can include country, state, and taxability for jurisdiction and exemption information.

Use Money::of('19.80', 'EUR') for major units or Money::ofMinor(1980, 'EUR') for minor units. If you use direct discount/tax array constructors instead of Money, their numeric amounts are in minor units; PdfInvoice::make() uses major units throughout.

Parties, Addresses, and Custom Fields

Use Party for the seller and buyer. Add billing and shipping addresses, contact details, tax IDs, registration identities, and custom fields as shown in the full example.

Custom fields can appear in the invoice header, party details, or addresses:

Types, States, and Dates

Built-in document types and states have translated labels:

For custom labels, use your own enum implementing Elegantly\Invoices\Contracts\HasLabel.

Set created_at, due_at, and paid_at to display dates. Change their format with invoices.date_format.

Payment Instructions and QR Codes

Add bank details, payment links, and QR codes with paymentInstructions:

Payment fields and invoice descriptions support HTML. Generate QR codes with a package such as chillerlan/php-qrcode.

Rendering, Downloading, and Storing PDFs

stream() displays the PDF inline; download() downloads it. The default filename is the serial number followed by .pdf.

Livewire Downloads

In resources/views/livewire/invoice-preview.blade.php:

Accessing Dompdf

pdf() returns an unrendered Dompdf instance. Override configured options, paper settings, or view data for a particular render:

Rendering Blade Views

To embed the invoice in another Blade view:

The partial uses Tailwind CSS classes. Include the package's invoices::default.style partial or provide equivalent styles in your application. The complete default layout already includes the package's CSS.

PDF Mail Attachments

Attaching PDFs to Mailables

Send the PDF built in the full example:

Attaching PDFs to Notifications

PDF Customization and Localization

Logos, Templates, and Template Data

Set logo to an image path or data URI, or configure a default with invoices.pdf.logo.

Publish views to customize the layout, invoice content, header, footer, and payment instructions:

Edit files in resources/views/vendor/invoices/. For a layout at resources/views/vendor/invoices/my-custom/layout.blade.php, use template: 'my-custom.layout' or set invoices.pdf.template.

Pass custom template settings through templateData, and extra Blade variables through view($data) or pdf(data: ...). Add styles for custom classes in style.blade.php.

Fonts and PDF Options

The default layout reads font and fonts from templateData:

You can set these defaults in invoices.pdf.template_data. Configure Dompdf's font directories, cache, remote resources, and other options through invoices.pdf.options. See the Dompdf font guide.

Localization and Money Formatting

Built-in type/state labels and template text use Laravel translations. Set your application locale and publish translations to customize them:

Use format_money() in custom templates to format amounts with the application locale, or specify a locale:

Extending PdfInvoice

Extend PdfInvoice to customize behavior such as filenames:

The Invoice Eloquent Model

Store invoice snapshots and totals with Invoice, and their line amounts, discounts, and taxes with InvoiceItem.

Publish and run the migrations before using the models. Assign amounts using Money; the package handles database storage and currency.

Complete Example

The transaction saves the invoice and its items together.

Stored Amounts and Denormalization

Line amounts and invoice totals are stored separately:

Item attribute Meaning Invoice attribute
unit_price Price of one unit before discounts and taxes. —
price_subtotal Normally unit_price × quantity. subtotal_amount
price_discount Sum of line discounts. discount_amount
price_tax Sum of line taxes. tax_amount
price price_subtotal − price_discount + price_tax. total_amount

Use the same currency for an invoice and its items. Numeric amounts assigned to the models are in major units.

Calculating and Saving Amounts

denormalize() calculates missing line amounts and sums them into invoice totals.

Storing Precomputed Amounts

Supply amounts directly to preserve your own calculations or those of a payment provider:

You can mix precomputed and calculated amounts: denormalize() fills the gaps. Include discount and tax entries with their amounts for PDF breakdowns and exports.

Recalculating Existing Invoices

Existing derived amounts remain populated after you edit source data. Recalculate them explicitly:

force: true recalculates line amounts, percentage discounts and taxes, and invoice totals. Fixed amounts remain inputs.

Denormalizing with Artisan

Use the command to fill missing amounts or recalculate existing invoices in bulk:

Managing Invoice Items

Use saveWithItems() to persist the invoice and its items, or saveItems() for an already saved invoice. setItems() replaces the loaded collection; delete unwanted database rows explicitly through items().

You can also manage items through the items() Eloquent relation. Reload items and use denormalize(force: true) to refresh calculated totals after changes.

For fractional quantities, change the published integer quantity column to a decimal column in your application's migrations.

Deleting an invoice deletes its items by default. Set invoices.cascade_invoice_delete_to_invoice_items to false to disable the model's cascading delete behavior.

Stored Discounts and Taxes

Add percentage or fixed-amount discounts and taxes with the item helpers:

Use Money for amounts. Direct discount/tax array constructors interpret numeric amounts with a currency key in minor units.

Stored Parties, Fields, and Payment Instructions

Store seller and buyer details in seller_information and buyer_information so invoices retain their original details when customer records change. Include addresses, contact details, tax IDs, and registration identities as needed.

fields appear in the PDF header; mergeFields() adds to existing fields. Use metadata for application data that should not appear on the invoice.

Payment instructions appear in the PDF and can include bank details, HTML payment links, and QR codes through qrcode.

Relations, Quotes, and Credits

Associate an invoice with any Eloquent model through its polymorphic relations:

Define the inverse relation on your customer model:

Invoices can also relate to other invoices through parent_id:

Types, States, and Query Scopes

New invoices default to type invoice and state draft. Available values are:

Set the state and state_set_at when your application records a payment or refund. Use query scopes to filter documents:

Type scopes are invoice(), quote(), and credit(). State scopes are draft(), pending(), paid(), and refunded().

To display a paid date in the PDF, set paid_at on the converted PdfInvoice.

Generating Serial Numbers

Serial numbers are generated automatically when an invoice is saved without one. The default format, PPYYCCCC, produces values such as IN260001.

Token Meaning
P Prefix
S Series
Y Year
M Month
C Sequential count

Repeat a token to set its width, and add separators as needed.

Multiple Prefixes and Series

Numbering is sequential within each prefix, series, year, and month. Override getPreviousInvoice() in a custom model to change that scope.

Set default numbering rules in configuration:

Manual Serial Numbers and Parsing

Manual numbers are preserved. Set invoices.serial_number.auto_generate to false if your application always supplies them.

Use SerialNumberGenerator independently to generate or parse numbers without a model:

Storing Logos

Without a stored logo, PDFs fall back to invoices.pdf.logo. To capture a logo in the database, store its binary contents:

Converting Models to PDFs

Use toPdfInvoice() to render the stored invoice without recalculating its amounts:

In routes/web.php:

For a Blade preview, include invoices::default.invoice with the converted PDF as invoice and include the package's CSS.

Livewire Downloads from a Model

In resources/views/livewire/invoice-download.blade.php:

Mount it in a Blade view with your stored invoice:

Customizing PDF Output from the Model

Extend the model and override toPdfInvoice() to adjust the returned PDF:

Register the model through invoices.model_invoice. You can also return your own PdfInvoice subclass, or configure global PDF settings under invoices.pdf.

Model Mail Attachments

Attach a stored invoice directly to mailables and notifications.

Mailables

Customize the filename with $invoice->toPdfInvoice()->toMailAttachment(filename: 'invoice.pdf').

Notifications

Replicating, Scaling, and Allocating Amounts

Replicating and Scaling

Replicate an invoice and its items to create a new document. For example, create a credit with negative amounts:

The copy receives a new serial number. multiplyBy() scales invoice, item, discount, and tax amounts without changing quantities or percentages. Use a string such as '0.5' for decimal factors.

Allocating Amounts

Allocate target amounts proportionally across existing items, for example to create a partial credit or match a payment provider's totals:

Allocation uses existing item and breakdown amounts as proportions, and updates unit prices, discounts, and taxes. Start with calculated amounts and nonzero quantities. Save without forced denormalization to preserve the allocated result.

Collections and Money Totals

Use sumMoney() to total amounts in the same currency, or convert collections to PDFs:

Importing Stripe Checkout Line Items

Install the optional Stripe SDK:

Import Stripe Checkout line items while preserving Stripe's precomputed amounts and breakdowns:

Use the expansions shown above and fetch all pages for larger sessions. toInvoiceItem($lineItem) imports a single line. Your application supplies invoice parties, dates, and associations; denormalize() sums the imported amounts without overwriting them.

GOBL Export

Export an invoice using the GOBL invoice schema:

The export includes document details, parties, lines, discounts, taxes, payment terms, and a reference to the parent invoice where applicable.

Pass additional values to extend or override the mapping:

Items, parties, discounts, and taxes can also be exported individually with toGOBL().

Custom Models and Value Objects

Extend the package classes and register your subclasses in config/invoices.php:

Use seller_class and buyer_class to configure separate party classes if needed.

Factories are available through Invoice::factory() and InvoiceItem::factory(). Invoice factories include invoice(), quote(), credit(), and proforma() states.

Casting Types and States to Enums

If you prefer enum attributes, merge enum casts with the parent's casts. Also override getType() and getState() to return the cast values for PDF conversion:

Set invoices.model_invoice to this subclass. For custom enums, implement Elegantly\Invoices\Contracts\HasLabel to provide PDF labels, and configure serial numbers for your custom document types.

Testing

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

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

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-invoices with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
dompdf/dompdf Version ^3.1
elegantly/laravel-money Version ^4.2.0
illuminate/contracts Version ^13.0
spatie/laravel-package-tools Version ^1.14
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package finller/laravel-invoices contains the following files

Loading the files please wait ...