flug / invoice
一个简单的发票生成器
dev-master
2021-09-23 11:39 UTC
Requires
- php: ^7.4
- ext-bcmath: *
- dompdf/dompdf: ^0.8.5 || ^1.0.0
- symfony/twig-pack: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16 || ^3.0
- phpspec/phpspec: ^6.1 || ^7.0
- dev-master
- dev-dependabot/npm_and_yarn/minimist-1.2.8
- dev-dependabot/npm_and_yarn/qs-6.5.3
- dev-dependabot/npm_and_yarn/decode-uri-component-0.2.2
- dev-dependabot/composer/dompdf/dompdf-tw-0.8.5or-tw-1.0.0or-tw-2.0.0
- dev-dependabot/npm_and_yarn/semantic-release-19.0.3
- dev-dependabot/npm_and_yarn/semver-regex-3.1.4
- dev-dependabot/npm_and_yarn/node-fetch-2.6.7
- dev-dependabot/npm_and_yarn/trim-off-newlines-1.0.3
- dev-dependabot/add-v2-config-file
- dev-fix/php-cs-fixer/config
- dev-remove/hirak/prestissimo
This package is auto-updated.
Last update: 2024-09-04 21:13:24 UTC
README
Flug Invoice 是一个用于 Symfony 的小型库/包,可以帮助您快速生成 PDF 发票,它不使用 wkhtmltopdf,而是使用 dompdf 或您可以在此处找到文档。您可以通过实现接口 "Flug\Invoice\ConfigurationInterface" 来按需重载。
完整的依赖注入配置在此处可用
#flug_invoice.yaml flug_invoice: currency: EUR decimal: 2 logo: file: 'https://i.imgur.com/yRb1NQ7.png' height: 60 business_details: name: My Company id: 1234567890 phone: +34 123 456 789 location: Main Street 1st zip: 08241 city: Barcelona country: Spain footnote: '' tax_rates: - {name: '' , tax: 0 , type: percentage} due: format: M dS ,Y date: +3 months with_pagination: true duplication_header: false display_images: true template: '@FlugInvoice/default.html.twig'
发票模板使用 twigphp/twig 渲染引擎。
代码示例
<?php use Flug\Invoice\Generator\Invoice; use Symfony\Component\HttpFoundation\Response; $invoice = new Invoice(); $invoice->setName('Best Invoice'); $invoice->setNumber((string) 1234556325); $invoice->setDate(new \DateTimeImmutable()); $invoice->setCustomerDetails('Best Customer', (string) 1234556, '+33 630301023', '44000', 'Nantes', 'France', '36 quai des orfèvres'); $invoice->addItem('Test Item', 10.25, 2, 1412) ->addItem('Test Item 3', 15.55, 5, 42) ->addItem('Test Item 4', 1.25, 1, 923) ->addItem('Test Item 5', 3.12, 1, 3142) ->addItem('Test Item 6', 6.41, 3, 452) ->addItem('Test Item 7', 2.86, 1, 1526) ->addItem('Test Item 8', 5, 2, 923, 'https://dummyimage.com/64x64/000/fff') ->setNotes('toto notes <br>'); $renderer = $this->pdf->generate($invoice); $stream = $renderer->output(); return new Response($stream, 200, ['Content-type' => 'application/pdf']);
更多测试即将到来...