PHPackages                             progicharles/doc-template - 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. [PDF &amp; Document Generation](/categories/documents)
4. /
5. progicharles/doc-template

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

progicharles/doc-template
=========================

Convert docx and xlsx files templates into PDF.

v1.0.0(5y ago)031MITPHPPHP ~7.0

Since Jan 18Pushed 3y agoCompare

[ Source](https://github.com/progicharles/doc-template)[ Packagist](https://packagist.org/packages/progicharles/doc-template)[ RSS](/packages/progicharles-doc-template/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Document Designer is a [Laravel](https://laravel.com) package allowing to generate documents from a template and filling it with some user data. The current version of PHPWord supports Microsoft Office Open XML (OOXML or OpenXML)

Document Designer is based on [PHPWord](https://github.com/PHPOffice/PHPWord). [LibreOffce](https://www.libreoffice.org) need to be installed on the server for PDF export.

Features
--------

[](#features)

- Template processing from .docx files
- Template processing from .xslx files
- Export in .docx, .xlsx &amp; .pdf fomat
- Text variable replacement
- Table row repetition
- Recursive blocks repetition

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

[](#installation)

#### Package

[](#package)

```
composer require uccello/document-designer-core
```

#### LibreOffice

[](#libreoffice)

You can refer to the [oficial documentation from LibreOffice](https://www.libreoffice.org/get-help/install-howto/) for the installation on your server OS.

Getting Started
---------------

[](#getting-started)

You just need to specify a template file, a out file name and the dataset to be used to parse and populate the template:

```
DocumentIO::process($templateFile, $outFile, $data);
```

The `$data` should be an associative array containing all the variables and the corresponding data to be replaced.

Depending the extension (.docx or .pdf) given in the `$outFile`, the export format will be DOCX or PDF.

#### Variables

[](#variables)

```
$data = [
    'variableName' => 'Content of the variable',
    'otherVariable' => 'Other content',
]
```

And in the template document, you need to declare the variables with the syntax : **${variableName}**

#### Tables

[](#tables)

Table keys in the associative array needs a `t:` prefix.

```
$data = [
    't:variableName' => [
        [
            'variableName' => 'dolor',
            'otherVariable' => 'elit',
        ],
        [
            'variableName' => 'amet',
            'otherVariable' => 'elit',
        ],
    ],
]
```

In the template document, you need to declare the variables with the syntax : **${variableName}**

The first row of the all template document containing a variable with the the same name as the table key will be repeated and the content of the other variables will be replaced.

#### Images

[](#images)

Image keys in the associative array needs a `i:` prefix.

```
$data = [
    'i:imgVariable' => 'path/image.jpg',
]
```

And in the template document, you need to declare the variables with the syntax : **${imgVariable:\[width\]:\[height\]:\[ratio\]}**

#### Blocks

[](#blocks)

Block keys in the associative array needs a `b:` prefix and with capital letters.

```
$data = [
    'b:BLOCK_NAME' => [
        [
            'variableName' => 'dolor',
            'otherVariable' => 'elit',
        ],
        [
            'variableName' => 'amet',
            'otherVariable' => 'elit',
        ],
    ]
]
```

In the template document, you need to declare the blocks start and end with flags :

**${BLOCK\_NAME}**

Block content...

**${/BLOCK\_NAME}**

The blocks behave recursively, witch means they can contain variables, tables and others block.

If a block contain a variable with a name in conflict with another variable in a parent block, the deeper block variables will be replaced in priority.

### Exemple:

[](#exemple)

##### Php

[](#php)

```
use Uccello\DocumentDesignerCore\Support\DocumentIO;

$templateFile = "path/template.docx";
$outFile = "path/out.pdf";

$data = [
    'var1' => 'lorem',
    'var2' => 'ipsum',
    'img1' => 'path/image.jpg',
    't:tVar1' => [
        [
            'tVar1' => 'dolor',
            'tVar2' => 'sit',
        ],
        [
            'tVar1' => 'amet',
            'tVar2' => 'consectetur',
        ],
    ],
    'b:BLOCK' => [
        [
            'var1' => 'adipiscing',
            'var2' => 'elit',
        ],
        [
            'var1' => 'sed',
            'var2' => 'do',
        ],
        [
            'var1' => 'eiusmod',
            'var2' => 'tempor',
        ],
    ]
];

DocumentIO::process($templateFile, $outFile, $data);
```

##### Template.docx

[](#templatedocx)

This is a simple test template content with two variables **${var1}** and **${var2}**

With an image:

**${img1:300:200}**

With a table:

Table variable 1Table variable 2**${tVar1}****${tVar2}**And a block:

**${BLOCK}**

This is a block content with two variables **${var1}** and **${var2}**

**${/BLOCK}**

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1941d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e86ab10956c9af81edb8c18a3f784f81a55e7e9ce430b9241c633fe71e71f8cf?d=identicon)[progicharles](/maintainers/progicharles)

---

Top Contributors

[![sardoj](https://avatars.githubusercontent.com/u/3235898?v=4)](https://github.com/sardoj "sardoj (4 commits)")[![progicharles](https://avatars.githubusercontent.com/u/93613494?v=4)](https://github.com/progicharles "progicharles (1 commits)")

### Embed Badge

![Health badge](/badges/progicharles-doc-template/health.svg)

```
[![Health](https://phpackages.com/badges/progicharles-doc-template/health.svg)](https://phpackages.com/packages/progicharles-doc-template)
```

###  Alternatives

[maatwebsite/excel

Supercharged Excel exports and imports in Laravel

12.7k144.3M712](/packages/maatwebsite-excel)[bfinlay/laravel-excel-seeder

Seed the database with Laravel using Excel, XLSX, XLS, CSV, ODS, Gnumeric, XML, HTML, SLK files

3944.4k](/packages/bfinlay-laravel-excel-seeder)[abydahana/aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based), just by writing single controller. Yet it's reusable, scalable and ready to use!

1101.2k](/packages/abydahana-aksara)[nilgems/laravel-textract

A Laravel package to extract text from files like DOC, XL, Image, Pdf and more. I've developed this package by inspiring "npm textract".

195.2k](/packages/nilgems-laravel-textract)

PHPackages © 2026

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