PHPackages                             aramirez92/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. aramirez92/docxmustache

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

aramirez92/docxmustache
=======================

docx template manipulation class, based on mustache templating language

v0.0.33(6y ago)1103MITPHPPHP &gt;=7.1.0

Since May 7Pushed 3y agoCompare

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

READMEChangelogDependencies (3)Versions (44)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 6.0.*
===============================

[](#docxmustache-for-laravel-60)

[![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 6.0, 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)This package helps you to use docx files with mustache syntax as templates to merge richly styled documents with information from any data source. It can replace text and images and supports basic html styling (bold, itallic, underline).

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

[](#installation)

`composer require wrklst/docxmustache`

Please check depencies down below and examples folder for configuration and usage.

HTML conversion
---------------

[](#html-conversion)

Current HTML conversion is basic and only supports singular runs of bold, italic and underlined text and no combination of these. It requires all values non html to be escaped with `htmlspecialchars($value, ENT_COMPAT, 'UTF-8');`and a prefix of `*[[DONOTESCAPE]]*`so the class knows not to escape the html before it is converted to openXML.

Replacing images
----------------

[](#replacing-images)

The image needs to be a reachable URL with a image in a supported format. The url value needs to be placed into the alt text description field of the image. Images will be resampled to the constraints of the placeholder image. The Image value needs to be formated the with pseudo tags around, such as: `[IMG-REPLACE]http://placehold.it/350x150[/IMG-REPLACE]`

Example
-------

[](#example)

Please also checkout the example in the example folder to get a basic understand of how to use this class.

DOCX to PDF conversion
----------------------

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

Conversion to PDF requires `libreoffice-common` to be installed on the server (used for conversion). Use `sudo apt install libreoffice-common` on your ubuntu/debian based server. Also install ttf-mscorefonts if you need support for Arial font when converting docx documents to pdf `sudo apt-get install ttf-mscorefonts-installer `

Other Dependencies
------------------

[](#other-dependencies)

The package is dependent on several Laravel specific functions. It could easily be ported to other frameworks or be ported to be framework agnostic. In addition to the Laravel dependency, the page uses the following packages:

- [mustache/mustache](https://packagist.org/packages/mustache/mustache)
- [intervention/image](http://image.intervention.io) (requires adding [provider and alias](http://image.intervention.io/getting_started/installation#laravel) to your app config as well as gd or imagick, [please check the image intervention webpage for details](http://image.intervention.io/getting_started/installation#laravel))

Laravel specific dependencies (only relevant if ported into non Laravel environment):

- [Storage and File class, based on Flysystem](https://flysystem.thephpleague.com) (for local file access, could also be replaced by phps own fopen etc methods)
- [\\Symfony\\Component\\Process\\Process](http://symfony.com/doc/current/components/process.html) (only for PDF conversion)

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

[](#contributions)

If you would like to contribute something to this package, please feel free to make a pull request and a corresponding issue and we will be happy to review and discuss.

Why another openXML / docx template solution?
---------------------------------------------

[](#why-another-openxml--docx-template-solution)

There are some classes out there that help with writing and or changing the content of word documents, some with commercial licenses and some free. For our particular purpose we did not need most of the features many of the libraries out there have – we needed a simple solution that would allow to replace values and images and traverse through data in a easy and straightforward manner.

Many of the other libraries use cloning to repeat a block with some custom templating syntax instead of using a existing template syntax. We use the usual mustache syntax, also to achieve repeating content in as many dimensions as needed.

Other PHP Classes to manipulate openXML word documents:

- [openTBS – Tiny But Strong](http://www.tinybutstrong.com/opentbs.php)
- [PHPWord](https://github.com/PHPOffice/PHPWord)
- [docxtemplater pro](https://modules.docxtemplater.com) (basic opensource / free version / MIT license available as of writing; image replacing is a commercial plugin)
- [docxpresso](http://www.docxpresso.com) (commercial)
- [phpdocx](https://www.phpdocx.com) (commercial)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 88.2% 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 ~28 days

Recently: every ~7 days

Total

33

Last Release

2395d ago

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

v0.0.31PHP &gt;=7.1.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c3d230104026a7496158b8c73b1ff6a00b69295f3b77507569d9b6aed84306b?d=identicon)[devOps92](/maintainers/devOps92)

---

Top Contributors

[![tobiasvielmetter](https://avatars.githubusercontent.com/u/5571166?v=4)](https://github.com/tobiasvielmetter "tobiasvielmetter (135 commits)")[![PSalador](https://avatars.githubusercontent.com/u/29531264?v=4)](https://github.com/PSalador "PSalador (5 commits)")[![aramirez92](https://avatars.githubusercontent.com/u/2057867?v=4)](https://github.com/aramirez92 "aramirez92 (4 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

phplaraveltemplateOpenXMLdocxmustache

### Embed Badge

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

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

###  Alternatives

[wrklst/docxmustache

docx template manipulation class, based on mustache templating language

578.1k](/packages/wrklst-docxmustache)

PHPackages © 2026

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