PHPackages                             wrklst/docxmustache - 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. [Templating &amp; Views](/categories/templating)
4. /
5. wrklst/docxmustache

ActiveLibrary[Templating &amp; Views](/categories/templating)

wrklst/docxmustache
===================

docx template manipulation class, based on mustache templating language

v0.0.52(1mo ago)578.7k↑33.3%19[2 issues](https://github.com/wrklst/docxmustache/issues)MITPHPPHP &gt;=8.1CI passing

Since May 7Pushed 1mo ago7 watchersCompare

[ Source](https://github.com/wrklst/docxmustache)[ Packagist](https://packagist.org/packages/wrklst/docxmustache)[ Docs](https://github.com/wrklst/docxmustache)[ RSS](/packages/wrklst-docxmustache/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (7)Versions (63)Used By (0)

[![DocxMutache Logo](https://github.com/wrklst/docxmustache/raw/master/example/logo.png)](https://github.com/wrklst/docxmustache/raw/master/example/logo.png)

DocxMustache *for Laravel 12.x.*
================================

[](#docxmustache-for-laravel-12x)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE) [![Quality Score](https://camo.githubusercontent.com/5af296c0723fdf2ac35e86d109b1c059ebeebdaaa9665cae1cd5d53426958e26/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f77726b6c73742f646f63786d757374616368652e7376673f7374796c653d666c61742d73717561726526623d6d6173746572)](https://scrutinizer-ci.com/g/wrklst/docxmustache/?branch=master) [![Build Status](https://camo.githubusercontent.com/4ec463e486c61b1cc34f31d7d88916f0161982a826eb5dffb8ad6d5ceb4942cc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f77726b6c73742f646f63786d757374616368652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/wrklst/docxmustache/build-status/master) [![StyleCI](https://camo.githubusercontent.com/9532d5e8df14ea012a261f61591823d3435d36f8bbefb95906fd1516d0e410d0/68747470733a2f2f7374796c6563692e696f2f7265706f732f39303438333434302f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/90483440)

Docx template manipulation class for Laravel 12.x, based on [mustache templating language](https://mustache.github.io). This class is still under heavy development and works more like proof of concept at the moment. Things will change quickly and might break things.

[![Template Example in Word](https://github.com/wrklst/docxmustache/raw/master/example/ExampleMustacheTemplate.png)](https://github.com/wrklst/docxmustache/raw/master/example/ExampleMustacheTemplate.png)

With DocxMustache, you can:

- Replace text using Mustache syntax.
- Embed images dynamically.
- Support basic HTML styling (bold, italic, underline).

---

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require wrklst/docxmustache
```

Refer to the [Examples](#example) section and the `examples` folder for configuration and usage instructions.

---

Features
--------

[](#features)

### HTML Conversion

[](#html-conversion)

Basic HTML conversion is supported, including:

- Bold (``)
- Italic (``)
- Underline (``)

**Limitations:**

- Does not support combined styling (e.g., bold + italic).
- Non-HTML values must be escaped using:

```
htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
```

**Special Note:**To prevent unnecessary escaping of HTML, prefix the value with:

```
*[[DONOTESCAPE]]*
```

---

### Replacing Images

[](#replacing-images)

Dynamic image replacement is supported. Follow these steps:

1. Add the image URL (reachable and supported format) to the image's **alt text description** field in the DOCX template.
2. Use pseudo-tags around the URL, like so:

```
[IMG-REPLACE]http://placehold.it/350x150[/IMG-REPLACE]

```

**Note:** Images will be resampled to match the constraints of the placeholder image in the template.

---

### DOCX to PDF Conversion

[](#docx-to-pdf-conversion)

To enable DOCX-to-PDF conversion, install `libreoffice-common` on your server:

```
sudo apt install libreoffice-common
```

For Arial font support, install:

```
sudo apt-get install ttf-mscorefonts-installer
```

---

Dependencies
------------

[](#dependencies)

### Required Packages

[](#required-packages)

- [mustache/mustache](https://packagist.org/packages/mustache/mustache)
- [intervention/image](http://image.intervention.io)

For Intervention Image, ensure you:

1. Add the [provider and alias](http://image.intervention.io/getting_started/installation#laravel) to your app config.
2. Install `gd` or `imagick` as required ([details here](http://image.intervention.io/getting_started/installation#laravel)).

### Laravel-Specific Dependencies

[](#laravel-specific-dependencies)

If you want to port the package to a non-Laravel environment, consider replacing:

- **Storage and File Classes**: Based on [Flysystem](https://flysystem.thephpleague.com), can be replaced with PHP native file handling.
- **Process Handling**: Uses `\Symfony\Component\Process\Process` for PDF conversion.

---

Example
-------

[](#example)

Check out the `examples` folder for sample templates and usage.

---

Contributions
-------------

[](#contributions)

Contributions are welcome! To contribute:

1. Fork the repository.
2. Create a pull request with your changes.
3. Include a corresponding issue for discussion.

We’ll be happy to review and discuss your ideas!

---

Why Another DOCX Templating Solution?
-------------------------------------

[](#why-another-docx-templating-solution)

While there are existing libraries for DOCX manipulation, they often:

- Use proprietary or non-standard templating syntaxes.
- Focus on complex feature sets, making them heavyweight for simple use cases.

DocxMustache was designed to:

- Use the widely adopted Mustache syntax.
- Provide simple and intuitive value and image replacement.
- Support repeating content in multiple dimensions.

### Alternatives

[](#alternatives)

Here are other popular PHP libraries for DOCX manipulation:

- [openTBS – Tiny But Strong](http://www.tinybutstrong.com/opentbs.php)
- [PHPWord](https://github.com/PHPOffice/PHPWord)
- [docxtemplater pro](https://modules.docxtemplater.com) (MIT licensed; image replacement requires a commercial plugin)
- [docxpresso](http://www.docxpresso.com) (commercial)
- [phpdocx](https://www.phpdocx.com) (commercial)

###  Health Score

60

—

FairBetter than 98% of packages

Maintenance90

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 92% 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

Every ~64 days

Recently: every ~16 days

Total

52

Last Release

46d ago

PHP version history (3 changes)v0.0.1PHP &gt;=5.3.0

v0.0.31PHP &gt;=7.1.0

v0.0.35PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f3f6bd1edba627327dfd6ef024d090169ac7c084e0e9df71e6c9ff9ad20b970?d=identicon)[wrklst](/maintainers/wrklst)

---

Top Contributors

[![tobiasvielmetter](https://avatars.githubusercontent.com/u/5571166?v=4)](https://github.com/tobiasvielmetter "tobiasvielmetter (161 commits)")[![PSalador](https://avatars.githubusercontent.com/u/29531264?v=4)](https://github.com/PSalador "PSalador (5 commits)")[![maffmeier](https://avatars.githubusercontent.com/u/2385541?v=4)](https://github.com/maffmeier "maffmeier (4 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (4 commits)")[![fabioolima](https://avatars.githubusercontent.com/u/5039814?v=4)](https://github.com/fabioolima "fabioolima (1 commits)")

---

Tags

docxdocxtemplaterlaravel-5-packagemicrosoft-wordmoustachemustachemustache-templatesopenxmlpdfphp-libraryreportingwordphplaraveltemplateOpenXMLdocxmustache

### Embed Badge

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

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

PHPackages © 2026

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