Download the PHP package maestrodimateo/simple-word without Composer
On this page you can find all versions of the php package maestrodimateo/simple-word. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maestrodimateo/simple-word
More information about maestrodimateo/simple-word
Files in maestrodimateo/simple-word
Package simple-word
Short Description A simple, dev-friendly Laravel wrapper for PHPWord
License MIT
Informations about the package simple-word
Simple Word
A simple, dev-friendly Laravel wrapper for PHPWord.
Built on top of PHPWord's TemplateProcessor, this package provides a fluent API for generating Word documents from .docx templates — with variables, tables, images, conditional blocks, PDF conversion, and Mailable-style template classes out of the box.
Installation
Publish the config:
Add to your .env (optional):
By default, templates are resolved from resources/templates/word.
Quick Start
Replace placeholders
In your .docx template, use ${variable} placeholders:
Hello ${name}, your order ${ref} was placed on ${date}.
Bulk replace
Nested arrays (dot notation)
Nested associative arrays are automatically flattened with dot notation. This is useful for grouping related data:
This replaces ${client.name}, ${client.email}, ${client.address.city}, ${client.address.zip}, and ${date} in the template.
Tables
In your template, prefix table cell placeholders with a group name. See PHPWord cloneRowAndSetValues:
| ${items.produit} | ${items.prix} |
|---|
The table row is cloned once for each entry and placeholders are filled automatically.
Images
Use ${placeholder} in your template where an image should appear. See PHPWord setImageValue:
Local file
Remote URL (GED, CDN, Alfresco, etc.)
image() accepts HTTP/HTTPS URLs. The image is downloaded automatically to a temp file:
From a Laravel filesystem disk
Use imageFromDisk() to load images from any configured Laravel filesystem disk (S3, SFTP, custom Alfresco adapter, etc.):
Conditional Blocks
In your template, wrap conditional content with block markers:
${has_discount} You benefit from a 10% loyalty discount! ${/has_discount}
When the condition is true, the content is kept (markers removed). When false, the entire block is removed.
Template Classes (Mailable-style)
For reusable, testable templates, generate a dedicated class:
This creates app/Word/InvoiceDocument.php:
Use it anywhere:
PDF Conversion
Convert any document to PDF with toPdf():
Supported drivers
| Driver | Requires | Quality |
|---|---|---|
libreoffice (default) |
LibreOffice installed on server | Excellent |
gotenberg |
Gotenberg Docker container | Excellent |
Configuration
Custom converter
Implement the PdfConverter interface for any other conversion service:
Output Methods
All output methods are available on both DocumentBuilder (docx) and PdfBuilder (after toPdf()):
| Method | Description |
|---|---|
save($path) |
Save to a local file path |
saveTo($disk, $path) |
Save to a Laravel filesystem disk (S3, local, etc.) |
download($filename) |
Return a download HTTP response |
stream($filename) |
Return an inline HTTP response (preview in browser) |
Advanced Usage
Access the underlying PHPWord TemplateProcessor for features not covered by the fluent API:
Facade
Helper
Configuration
Artisan Commands
| Command | Description |
|---|---|
make:word-template |
Generate a new WordTemplate class |
Testing
Useful PHPWord Links
- PHPWord Documentation
- Template Processing — setValue, cloneRow, cloneBlock, setImageValue
- Elements — text, tables, images, lists, headers/footers
- Styles — fonts, paragraphs, tables
- Writers — Word2007, ODText, HTML, PDF
- GitHub Repository
License
MIT
Credits
- Noel Mebale
- Built on PHPOffice/PHPWord
All versions of simple-word with dependencies
phpoffice/phpword Version ^1.3
illuminate/support Version ^12.0|^13.0
symfony/process Version ^7.0|^8.0