Download the PHP package beziworld/laravel-docx-templates without Composer

On this page you can find all versions of the php package beziworld/laravel-docx-templates. 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-docx-templates

Laravel DOCX Templates

tests Latest Version

Fill Word (.docx) templates in Laravel: contracts, invoices, certificates, letters. A Laravel layer over PHPWord's TemplateProcessor:

Polska wersja dokumentacji

Why this package

PHPWord has 49 million downloads, but its Laravel wrappers are small. The most downloaded ones on Packagist (November 2026): novay/laravel-word-template 22k, santwer/exporter 3.7k, the rest below 1k.

santwer/exporter is a capable package built around export classes with concerns (in the style of Laravel Excel), with charts, checkboxes, batch exports and PDF through LibreOffice. It resolves templates from absolute paths or storage_path(). This package takes a different route:

santwer/exporter this package
Template location absolute path or storage_path() any filesystem disk, local path or bytes
Output download, file, PDF disk (store()), local file, download, inline, Responsable, PDF
Document definition export class with concerns TemplateDefinition with typed constructor, required() placeholders
Unresolved placeholders not documented strict mode fails and lists them
Eloquent hidden attributes not documented never rendered (toArray() keys)
PDF in tests needs LibreOffice Process::fake()
Charts, checkboxes, batch exports yes no

novay/laravel-word-template is a fluent wrapper with values, images, loops, watermarks and merging, reading templates from paths. enflow/document-replacer (39k, framework-agnostic) replaces values and converts through unoserver.

Installation

Requirements: PHP 8.3+, Laravel 12 or 13, ext-zip, ext-dom. LibreOffice only for PDF.

Template syntax

Placeholders use the PHPWord syntax, typed in Word as plain text:

In the template Filled with
${number}, ${customer.address.city} a value (dot notation reads nested data)
${discount} ... ${/discount} (each marker in its own paragraph) a block: kept, removed or repeated
${item.name} in a table row the row is repeated per item
${logo} or ${logo:120:60} an image
${summary} alone in a paragraph a generated table

Word sometimes splits text into several runs while you type; PHPWord repairs most split placeholders. Run php artisan docx:variables invoice.docx to see the placeholders the package finds.

Filling a template

Shortcuts on the template: ->store(), ->save(), ->download(), ->pdf().

Lists and booleans in the data fill blocks automatically: with ['discount' => false] the ${discount}...${/discount} block disappears, with a list it is repeated. An empty list removes a block or a table row.

Other template sources:

Values and escaping

Value Written as
string, int, float escaped text (&, <, >, quotes), like Blade {{ }}
null empty
bool booleans.true / booleans.false from the config (1 / empty, like Blade)
DateTimeInterface (also Eloquent date casts) date_format from the config
backed enum / unit enum value / name
Stringable its string
Raw::xml('...'), DocxTemplates::raw(), any Htmlable inserted without escaping, like {!! !!}
array or list only through blocks, rows or tables; otherwise InvalidValue

Characters that XML 1.0 forbids are removed and invalid UTF-8 is replaced, so user input cannot corrupt the document. New lines become <w:br/> and tabs <w:tab/> (line_breaks in the config). PHPWord's own global output escaping setting is left untouched and restored after rendering.

Raw markup goes inside a w:t element, so it usually closes and reopens the run, for example Raw::xml('</w:t><w:br/><w:t>'). Never wrap user input in Raw.

Eloquent models

with($model) reads the keys of $model->toArray(), which means visible attributes, $appends accessors and loaded relations, and takes their values from getAttribute() so that casts keep their type (dates are formatted with date_format). Attributes in $hidden are never available to a template. Load the relations a template needs before rendering ($invoice->load('customer', 'items')).

Template definitions

One class per document type keeps the template, the data mapping and the requirements together:

Other hooks: disk() (template disk) and strict().

PDF

The converter runs soffice --headless --norestore --nolockcheck --nodefault -env:UserInstallation=<temporary profile> --convert-to pdf --outdir <temporary directory> <file> through Laravel's Process with the configured timeout. The command is an argument list (no shell); the temporary profile is removed afterwards, so parallel queue workers do not share one LibreOffice instance. A non-zero exit code, a timeout or a missing output file raise ConversionFailed with LibreOffice's error output. Bind your own Beziworld\DocxTemplates\Pdf\PdfConverter to use another engine (Gotenberg, unoserver).

In tests:

Artisan

Errors

Exception When
TemplateNotFound the template is missing on the disk or path, or is not a .docx (ZIP with word/document.xml)
UnresolvedPlaceholders strict mode and placeholders left; placeholders() lists them
TemplateMismatch a placeholder from require() / required() is missing in the template
InvalidValue a value without a text form, an array used as a value, an image that is missing or not an image
RenderingFailed PHPWord failed, a row anchor is missing, a file cannot be written
ConversionFailed LibreOffice failed, timed out or wrote no PDF
InvalidConfiguration invalid timeout or temporary directory

All exceptions extend Beziworld\DocxTemplates\Exceptions\DocxTemplatesException.

Limits

Development

Test templates are generated at runtime with PHPWord; LibreOffice is faked with Process::fake().

Author

Created and maintained by Kamil Ćwiertnia, beziworld.eu.

Need an integration? Get in touch through beziworld.eu.

License

MIT. See LICENSE.md. PHPWord is licensed under LGPL-3.0 by its authors. This package is not affiliated with or endorsed by the PHPOffice project, Microsoft or The Document Foundation.


All versions of laravel-docx-templates with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-dom Version *
ext-zip Version *
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/process Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
phpoffice/phpword Version ^1.4
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 beziworld/laravel-docx-templates contains the following files

Loading the files please wait ...