PHPackages                             invoice/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. [Payment Processing](/categories/payments)
4. /
5. invoice/invoice

ActiveLibrary[Payment Processing](/categories/payments)

invoice/invoice
===============

Simple Php Class For Beautiful Invoices

v1.0(7y ago)55229↓100%13MITPHPPHP ^7.0.0

Since May 8Pushed 6y agoCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Invoice
=======

[](#invoice)

[English Document](README.en.md)

[港澳台繁體文档](README.hk.md)

只需几行代码即可生成设计精美的报价单或订单。使用您自己的徽标和主题颜色进行品牌化，使用自动分页添加无限制的项目和总行数。您可以在用户的​​浏览器中传送PDF输出，保存在服务器上或强制下载文件 Invoice内置了中文简体、中文繁体、英语的翻译，您可以设置每个文档所需的货币。

项目已集成[ 思源黑体(Source Han Sans)](https://github.com/Pal3love/Source-Han-TrueType)中文版

安装Invoice
---------

[](#安装invoice)

Invoice利用Composer来管理其依赖关系。 因此，在使用Invoice之前，请确保在您的计算机上安装了Composer

```
composer require invoice/invoice
```

演示
--

[](#演示)

[苹果报价表](https://invoice.ofan.cn/)

货币
--

[](#货币)

[货币代码](document/Currency.cn.md)

文档
--

[](#文档)

### 实例

[](#实例)

```
use Invoice\Invoice;
$invoice=new Invoice();
```

or

```
$invoice=get_invoice();
```

### 例

[](#例)

```
$invoice = new Invoice('CNY','A4');

//Set number formatting
$invoice->setNumberFormat('.',',')

//设置字体
//->setFontFamily('SourceHanSans', '', '~/font/sourcehansans.ttf')
//->setFontFamily('SourceHanSans','b', '~/font/sourcehansansb.ttf')

//设置LOGO
->setLogo("images/apple.png",100,88)
//设置颜色
->setColor("#ed4014")
//设置要文档类型
->setType("报价表")
//设置文档编号
->setReference(date('Ymd').'001')
//报价日期
->setDate(date('Y-m-d'))
//截止日期
->setDue(date('Y-m-d',strtotime('+3 months')))
//报价人
->setFrom(["Apple Inc","1 Infinite Loop","Cupertino, CA 95014","United States of America","IE9700053D"])
//客户
->setTo(["京东商城 刘强东","北京市","北京经济技术开发区科创","十四街99号2号楼B168室","400-6065500 "])
//新增产品
->addItem("Apple iPhone X","64G 红色",1,"21%",299,'5%',284.05)
->addItem("Apple iPhone X","158G 红色",1,"21%",299,0,299)
//增加合计
->addTotal("合计",583.05)
->addTotal("折扣 21%",122.44)
->addTotal("总计",705.5,true)
//增加李老师
->addTitle("声明")
//添加段落
->addParagraph("只需几行代码即可生成设计精美的报价单或订单\nInvoice利用Composer来管理其依赖关系。 因此，在使用Invoice之前，请确保在您的计算机上安装了Composer\ncomposer require invoice/invoice")
//设置页脚
->setFooternote("http://www.apple.com")
//设置徽章
->addBadge('A级机密')
//切换公司信息和客户信息的水平位置
->flipflop()
//交付PDF
->render('Apple.pdf','I');
```

### 类说明

[](#类说明)

```
    /**
     * 实例
     * @param string $currency
     *            货币代码
     * @param string $size
     *            纸张大小 A4 Letter Legal
     * @param string $language
     *            语言
     */
    function __construct($currency = 'CNY', $size = 'A4', $language = 'zh');

    /**
     * 获取货币符号
     *
     * @param string $code
     *            货币代码
     * @return string|null
     */
    public function getCurrencySymbol(string $code);

    /**
     * 判断货币是否可用
     *
     * @param string $code
     *            货币代码
     * @return bool
     */
    public function hasCurrency(string $code);

    /**
     * 设置字体
     *
     * @param string $family
     *            字体名称
     * @param string $style
     *            字体样式 至少包含两种字体样式 ''和'b'
     * @param string $file
     *            字体文件
     * @return $this
     */
    public function setFontFamily(string $family, string $style = '', string $file = '');

    /**
     * 设置语言
     *
     * @param string $language
     * @return $this
     */
    public function setLanguage(string $language);

    /**
     * 设置要文档类型
     *
     * @param type $title
     * @return $this
     */
    public function setType(string $title);

    /**
     * 设置颜色
     *
     * @param string $rgbcolor
     *            十六进制颜色代码。红色示例：'＃FF0000'
     * @return $this
     */
    public function setColor(string $rgbcolor);

    /**
     * 设置文档日期
     *
     * @param string $date
     * @return $this
     */
    public function setDate(string $date);

    /**
     * 截止日期
     *
     * @param string $date
     * @return $this
     */
    public function setDue(string $date);

    /**
     * 设置logo
     *
     * @param string $logo
     *            要使用的图像文件的本地路径或远程URL
     * @param int $maxWidth
     *            宽度 毫米为单位
     * @param int $maxHeight
     *            高度 毫米为单位
     * @return $this
     */
    public function setLogo($logo = 0, $maxWidth = 0, $maxHeight = 0);

    /**
     * 设置公司详细信息
     *
     * @param array $data
     * @return $this
     */
    public function setFrom(array $data);

    /**
     * 客户信息
     *
     * @param array $data
     * @return $this
     */
    public function setTo(array $data);

    /**
     * 设置文档编号
     *
     * @param string $reference
     * @return $this
     */
    public function setReference($reference);

    /**
     * 设置数字格式
     *
     * @param string $decimals
     *            小数点的字符
     * @param string $thousands_sep
     *            千位分隔符的字符
     * @return $this
     */
    public function setNumberFormat($decimals, $thousands_sep);

    /**
     * 新增商品
     *
     * @param string $item
     *            产品或服务名称
     * @param string $description
     *            描述 使用或\ n添加换行符
     * @param decimal $quantity
     *            数量
     * @param decimal|string $vat
     *            金额
     * @param decimal $price
     *            单价
     * @param string|decimal|boolean $discount
     *            折扣 没有请填 false
     * @param int $total
     *            总计
     * @return $this
     */
    public function addItem($item, $description, $quantity, $vat, $price, $discount, $total);

    /**
     * 设置总计
     *
     * @param string $name
     *            名称
     * @param decimal $value
     *            值
     * @param boolean $colored
     *            背景色 true 则背景色
     * @return $this
     */
    public function addTotal($name, $value, $colored = false);

    /**
     * 添加标题
     *
     * @param string $title
     * @return $this
     */
    public function addTitle($title);

    /**
     * 添加段落
     *
     * @param string $paragraph
     * @return $this
     */
    public function addParagraph($paragraph);

    /**
     * 添加徽章
     *
     * @param string $badge
     * @return $this
     */
    public function addBadge($badge);

    /**
     * 设置页脚
     *
     * @param string $note
     * @return $this
     */
    public function setFooternote($note);

    /**
     * 切换公司信息和客户信息的水平位置
     *
     * @return $this
     */
    public function flipflop();

    /**
     * 渲染交付
     *
     * @param string $name
     *            名称
     * @param string $destination
     *            交付方式
     *            I（将文件内联发送到浏览器）
     *            D（发送到浏览器并强制使用名称给出的名称下载文件）
     *            F（保存到本地文件。确保在name参数中设置传递路径）
     *            S（将文档作为字符串返回）
     * @return $this
     */
    public function render($name = '', $destination = '');
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2558d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4d8ec175cba785ce9881ae0f15648b88895bed17c6968a58a2ae436996a02bef?d=identicon)[invoice](/maintainers/invoice)

---

Top Contributors

[![ofancn](https://avatars.githubusercontent.com/u/38897378?v=4)](https://github.com/ofancn "ofancn (6 commits)")

---

Tags

invoice

### Embed Badge

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

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

###  Alternatives

[laraveldaily/laravel-invoices

Missing invoices for Laravel

1.5k1.3M4](/packages/laraveldaily-laravel-invoices)[horstoeko/zugferd

A library for creating and reading european electronic invoices

4044.3M17](/packages/horstoeko-zugferd)[atgp/factur-x

PHP library to manage your Factur-X / ZUGFeRD 2.0 PDF invoices files

138825.5k3](/packages/atgp-factur-x)[num-num/ubl-invoice

A modern object-oriented PHP library to create and read valid UBL and EN 16931/Peppol BIS 3.0 files

135820.5k](/packages/num-num-ubl-invoice)[anam/phantommagick

PhantomMagick provides a simple API to ease the process of converting HTML to PDF or images

161456.4k2](/packages/anam-phantommagick)[konekt/pdf-invoice

Library to generate PDF invoices

212200.7k](/packages/konekt-pdf-invoice)

PHPackages © 2026

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