Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Invoices, Quotes and Reports as Files
PHP Development

Invoices, Quotes and Reports as Files

Generating invoices, quotes and PDF reports from a PHP application: run it in the background, store what was produced, and keep templates maintainable.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Generate in the background, store what was produced rather than regenerating on demand, and make the template maintainable by someone who is not a developer.

Generate in the background

Document generation is slow and it can fail. Doing it during a web request means a user waiting and a request that sometimes times out.

Queue it, generate it, store it, and notify when it is ready. For a single invoice that feels like overkill until the day someone generates four hundred.

Store, do not regenerate

An invoice regenerated next year may look different, because the template changed, the tax rate changed or a product name was edited. The document you sent is the record; store it.
  • Store the generated file, not just the data
  • Record which template version produced it
  • Never overwrite a document that has been sent
  • Keep them for as long as your records policy requires

Templates need to be maintainable

Someone in the business will want to change the wording, the logo or the layout. If that requires a developer every time, it will not happen and the documents will go stale.

HTML templates rendered to PDF are usually the right approach: familiar, editable, and version-controllable.

The details that matter

  1. Page breaks that do not split tables awkwardly
  2. Fonts embedded, so it renders the same everywhere
  3. Page numbers and continuation headers on multi-page documents
  4. Correct number formatting for currency and dates
  5. Accessible output where recipients need it

Test with real data

Test caseWhy
A very long customer nameLayout overflow
Fifty line itemsPage breaks and totals
Zero line itemsEmpty state
A large currency amountNumber formatting
Accented charactersFont coverage

Documents that look correct on the sample data and break on real data are the standard failure mode here.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

Which PDF library should we use?

One that renders HTML and CSS well, so templates are maintainable. The specific choice matters less than that property.

Should invoices be regenerated on demand?

No. Store what was sent. Regeneration produces documents that differ from what the customer received.

What about emailing them?

Attach the stored file, and send through authenticated SMTP. Documents lost to spam filtering is a common and avoidable problem.

Can non-developers edit the templates?

With HTML templates, usually yes for wording and simple layout. That is worth designing for.

Keep reading

More on PHP Development

PHP Development

Why PHP Is Still a Sensible Choice

Is PHP still a good choice for business applications? Where modern, typed PHP fits, where another language is better, and the hosting and hiring arguments.

PHP Development

Improving Old Code Without a Rewrite

Modernising a legacy PHP application without a rewrite: move to a supported PHP version, add tests around what matters, then strangle rather than replace.

Start here

Invoices generated by hand from a spreadsheet?

Generating them from your data is a contained piece of work with an immediate saving.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →