PHPackages                             imos/invoice - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. imos/invoice

AbandonedArchivedLibrary[PDF &amp; Document Generation](/categories/documents)

imos/invoice
============

A library for creating invoices

1.2.0(5y ago)7472MITPHPPHP ^5.5 || ^7.0

Since Mar 22Pushed 5y ago6 watchersCompare

[ Source](https://github.com/imosnet/invoice)[ Packagist](https://packagist.org/packages/imos/invoice)[ RSS](/packages/imos-invoice/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (7)Used By (0)

Invoice
=======

[](#invoice)

[![Packagist](https://camo.githubusercontent.com/7e274af446d4873b01326b8be231c69f131d9ce61e27c222ef01987aba343390/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f696d6f732f696e766f6963652e737667)](https://packagist.org/packages/imos/invoice)[![Travis](https://camo.githubusercontent.com/867693822c86ce8ed20b6044c3512bddfd4b01605d3ff17c4b0ae534f25989df/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f696d6f736e65742f696e766f6963652e737667)](https://travis-ci.org/imosnet/invoice)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/imosnet/invoice/master/LICENSE)

imos Invoice is a library for creating and generating invoices.

Setup
-----

[](#setup)

This library relies on BCMath to do reliable calculations. Make sure [bcmath.scale](https://php.net/bcmath.scale) is set sufficiently high (it should at least be higher than the number of decimal places you will round to).

```
ini_set('bcmath.scale', 10);
// OR
bcscale(10);
```

Install [Twig](https://packagist.org/packages/twig/twig) and/or [mPDF](https://packagist.org/packages/mpdf/mpdf) to use `HtmlGenerator` or `MpdfGenerator`.

Building an Invoice
-------------------

[](#building-an-invoice)

`LineItem` represents a line item on your invoice. It holds basic information for each position.

```
$lineItem = (new LineItem)
    ->setDescription('Internet Widget')
    ->setReference('IW-42')
    ->setQuantity(2)
    ->setUnit('pc.')
    ->setUnitPrice(25)
    ->setTaxRate(19) // 19%
    ->setTaxName('VAT (DE)')
    ->setDiscount(20); // 20%

$lineItemTotal = $lineItem->getTotal(); // Get the line total
```

`Invoice` represents an invoice. It can be set to use either net list prices or gross list prices. Depending on type, it will calculate taxes either "backwards" or "forwards".

```
$invoice = (new Invoice)
    ->setPriceType(Invoice::PRICE_NET)
    ->setCurrency('EUR')
    // The number of decimal places used can be set with the second parameter
//  ->setCurrency('JPY', 0)

    ->setCustomerAddress(array(
        'imos GmbH',
        'Alfons-Feifel-Str. 9',
        '73037 Göppingen',
    ))
    ->setCustomerNumber('99999')
    ->setInvoiceNumber('RE-1234')
    ->setInvoiceDate(new DateTime)
    ->setDueDate(new DateTime('+30 days'))
    ->setBillingPeriod(DateRange::create('2016-01-01', '2016-02-01'))
    ->setCommission('ACME Partner')

    ->addTaxId('VATIN', 'DE999999999')
    ->addTaxId('Steuernummer', '12345 / 67890')

    ->setPaymentTerms('30 days strictly net')

    ->addExtraInfo('Payable by bank transfer.')
    ->addExtraInfo('IBAN: DE99 1234 5678 9012 3456 78')

// Add line items
    ->addLineItem($lineItem)
    ->addLineItem($lineItem);

$netTotal = $invoice->getTotal(Invoice::PRICE_NET); // 40
$grossTotal = $invoice->getTotal(Invoice::PRICE_GROSS); // 47.6
```

Line items are grouped by tax name and rate.

```
$taxes = $invoice->getTaxes();
/*
    array(
        array(
            'name' => 'VAT (DE)',
            'rate' => 19,
            'total' => 7.6,
        )
    )
*/
```

### Placeholders

[](#placeholders)

Text fields support the following placeholders, which are replaced with the corresponding values from the invoice:

- `{{totalNet}}` - Net total
- `{{totalGross}}` - Gross total
- `{{taxTotal}}` - Total tax
- `{{totalNetAbs}}` Net total (absolute value)
- `{{totalGrossAbs}}` Gross total (absolute value)
- `{{taxTotalAbs}}` Total tax (absolute value)
- `{{customerNumber}}`
- `{{invoiceNumber}}`
- `{{invoiceDate}}`
- `{{dueDate}}`
- `{{billingPeriod}}`
- `{{commission}}`

```
$invoice->addExtraInfo('This invoice covers services rendered {{billingPeriod}}.');
$invoice->addExtraInfo('Please transfer {{totalGross}} to our account by {{dueDate}}, ' .
                       'using "{{customerNumber}} / {{invoiceNumber}}" as the reference.');
```

Generating an Invoice
---------------------

[](#generating-an-invoice)

Generating an invoice is simple:

```
$generator = new HtmlGenerator(new Formatter);
echo $generator->generate($invoice);
```

The generated invoice can be customized for your locale and/or business:

```
$formatter = (new Formatter)
    ->setDecimalSeperator('.')
    ->setThousandsSeperator(',')
    ->setDateFormat('d.m.Y')
    ->setCurrencyFormat('%02$s %01$s')
    ->setStrings(array(
        'customer_number' => 'Kundennummer',
        'invoice_number' => 'Rechnungsnummer',
        'invoice_date' => 'Rechnungsdatum',
        'billing_period' => 'Abrechnungszeitraum',
        'commission' => 'Kommission',

        'item_description' => 'Bezeichnung',
        'item_reference' => 'Referenz',
        'item_quantity' => 'Menge',
        'item_unit' => 'Einheit',
        'item_unit_price' => 'Preis',
        'item_discount' => 'Rabatt',
        'item_total' => 'Summe',

        'payment_terms' => 'Zahlungsbedingungen',

        'price_net' => 'Netto',
        'price_gross' => 'Brutto',
    ));
$generator->setFormatter($formatter);
```

### The `HtmlGenerator`

[](#the-htmlgenerator)

In addition to the translation features, you can add CSS directly to the generated document:

```
$generator->addCSS('thead th {background: darkcyan;}');
$generator->addStylesheet(__DIR__ . '/custom.css');
```

You can also write your own Twig template to use (see the current ones under `resources/html_templates/` for a starting point):

```
$generator->addHtmlTemplatePath(__DIR__ . '/templates');
$generator->setHtmlTemplate('custom.twig');
```

### The `MpdfGenerator`

[](#the-mpdfgenerator)

The `MpdfGenerator` uses mPDF to generate a PDF invoice. In addition to the `generate()` method, MpdfGenerator can also return you the mPDF object directly.

```
$generator = new MpdfGenerator(new Formatter, new mPDF);
$generator->generateMpdf($invoice)->Output();
```

A PDF file can be set as a template for the invoice. A template usually consists of two pages, one for the first page of the invoice (with a letterhead, for example) and one for subsequent pages. The last page of the template is repeated if the invoice becomes longer that the template. Page margins can be set using CSS.

```
$generator
    ->setPdfTemplate('letterhead.pdf')
    ->addCss('@page { margin: 2.5cm 2cm; }
              @page :first { margin-top: 5.5cm; }');
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~313 days

Recently: every ~391 days

Total

6

Last Release

2133d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b69f1500c5f1709f1800f7cf76806d72a66b0d14c0b409ad98767710f973f60?d=identicon)[mimez](/maintainers/mimez)

---

Top Contributors

[![okj579](https://avatars.githubusercontent.com/u/40447?v=4)](https://github.com/okj579 "okj579 (1 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/imos-invoice/health.svg)

```
[![Health](https://phpackages.com/badges/imos-invoice/health.svg)](https://phpackages.com/packages/imos-invoice)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.2k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M100](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M128](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
