PHPackages                             mkdreams/mdword - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mkdreams/mdword

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mkdreams/mdword
===============

OFFICE WORD 动态数据 绑定数据 生成报告；OFFICE WORD Dynamic data binding data generation report.

1.1.9(6mo ago)521.3k10Apache-2.0PHPPHP &gt;=5.6.0

Since Mar 16Pushed 3mo ago2 watchersCompare

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

READMEChangelog (10)DependenciesVersions (15)Used By (0)

MDword
======

[](#mdword)

[中文文档](https://github.com/mkdreams/MDword/blob/main/README-CN.md)
-----------------------------------------------------------------

[](#中文文档)

Project General Name
--------------------

[](#project-general-name)

Template: a word which will be revised.
Block: the part which will be replaced or cloned.

Project Introduction
--------------------

[](#project-introduction)

Main Use: to generate word dynamically.
Advantage: focus only on dynamic data and logic, rather than adjusting the style, which can modulate the template with the help of office word.

Comparison between MDword &amp; PHPword
---------------------------------------

[](#comparison-between-mdword--phpword)

- ### Similarities

    [](#similarities)

1. PHP Package.
2. Both can be used to generate office word.

- ### Differences

    [](#differences)

1. PHPword concentrates on writing elements one by one. However, it is more powerful and efficient for Mdword just to revise them on the template.
2. For updating text styles, adding covers, headers and footers, MDword just modifies the template by office word, while PHPword complicate the task-adjusting every element.
3. Directories(Table of content) can be automatically generated.

Tutotials
---------

[](#tutotials)

- ### Installation

    [](#installation)

```
// Method 1
composer require mkdreams/mdword
// Method 2, Autoloading Template
require_once('Autoloader.php');

```

- ### Add annotations or use “${value/}” to the template. Please note that there is a “/” at the end.

    [](#add-annotations-or-use-value-to-the-template-please-note-that-there-is-a--at-the-end)

[![image](https://user-images.githubusercontent.com/12422458/111026036-1c647700-8423-11eb-9df2-e9a2e5530007.png)](https://user-images.githubusercontent.com/12422458/111026036-1c647700-8423-11eb-9df2-e9a2e5530007.png)

- ### Invocation Methods (more and richer approaches, for example: [tests\\samples\\simple for readme](https://github.com/mkdreams/MDword/blob/main/tests/samples/simple%20for%20readme/index.php), such as catalog, sequence number, etc.)

    [](#invocation-methods-more-and-richer-approaches-for-example-testssamplessimple-for-readme-such-as-catalog-sequence-number-etc)

```
// New class,load template
$TemplateProcessor = new WordProcessor();
$template = 'temple.docx';
$TemplateProcessor->load($template);

// Set Value
$TemplateProcessor->setValue('value', 'r-value');

// Clone
$TemplateProcessor->clones('people', 3);

$TemplateProcessor->setValue('name#0', 'colin0');
$TemplateProcessor->setValue('name#1', [
    ['text'=>'colin1','style'=>'style','type'=>MDWORD_TEXT],
    ['text'=>1,'type'=>MDWORD_BREAK],
    ['text'=>'86','style'=>'style','type'=>MDWORD_TEXT]
]);
$TemplateProcessor->setValue('name#2', 'colin2');

$TemplateProcessor->setValue('sex#1', 'woman');

$TemplateProcessor->setValue('age#0', '280');
$TemplateProcessor->setValue('age#1', '281');
$TemplateProcessor->setValue('age#2', '282');

// set value for image
$TemplateProcessor->setImageValue('image', dirname(__FILE__).'/logo.jpg');

// Delete a paragraph
$TemplateProcessor->deleteP('style');

// Save
$rtemplate = __DIR__.'/r-temple.docx';
$TemplateProcessor->saveAs($rtemplate);

```

- ### Result

    [](#result)

[![image](https://user-images.githubusercontent.com/12422458/111026037-1d95a400-8423-11eb-81e2-941f6b854e34.png)](https://user-images.githubusercontent.com/12422458/111026037-1d95a400-8423-11eb-81e2-941f6b854e34.png)

- ### GIFs

    [](#gifs)

[![image](https://user-images.githubusercontent.com/12422458/111026041-1ec6d100-8423-11eb-8e14-d8daf99a9704.gif)](https://user-images.githubusercontent.com/12422458/111026041-1ec6d100-8423-11eb-8e14-d8daf99a9704.gif)

More samples
------------

[](#more-samples)

- [Simple Comprehhensive cases](https://github.com/mkdreams/MDword/tree/main/tests/samples/simple%20for%20readme)
- [Formatted texts](https://github.com/mkdreams/MDword/tree/main/tests/samples/text)
- [Add images](https://github.com/mkdreams/MDword/tree/main/tests/samples/image)
- [Clone](https://github.com/mkdreams/MDword/tree/main/tests/samples/clone)
- [Many ways to set blocks, solving the lack of notes](https://github.com/mkdreams/MDword/tree/main/tests/samples/block)
- [Write element that is written by PHPword to the block](https://github.com/mkdreams/MDword/tree/main/tests/samples/phpword)
- [Put TOC in a table](https://github.com/mkdreams/MDword/tree/main/tests/samples/toc)
- [Merge table cells](https://github.com/mkdreams/MDword/tree/main/tests/samples/merge%20table%20cells)

Communication
-------------

[](#communication)

### Note: Exchange idea on MDword.

[](#note-exchange-idea-on-mdword)

[![image](https://user-images.githubusercontent.com/12422458/111025926-5a14d000-8422-11eb-86a3-db8a0ad712f0.png)](https://user-images.githubusercontent.com/12422458/111025926-5a14d000-8422-11eb-86a3-db8a0ad712f0.png)

[Project Plans](https://github.com/mkdreams/MDword/projects/1#column-10318470)
------------------------------------------------------------------------------

[](#project-plans)

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance74

Regular maintenance activity

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 99.7% 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 ~131 days

Recently: every ~191 days

Total

14

Last Release

187d ago

PHP version history (2 changes)1.0.0PHP &gt;=7.0.0

1.0.1PHP &gt;=5.6.0

### Community

Maintainers

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

---

Top Contributors

[![mkdreams](https://avatars.githubusercontent.com/u/12422458?v=4)](https://github.com/mkdreams "mkdreams (315 commits)")[![ximengyi](https://avatars.githubusercontent.com/u/16025658?v=4)](https://github.com/ximengyi "ximengyi (1 commits)")

---

Tags

office

### Embed Badge

![Health badge](/badges/mkdreams-mdword/health.svg)

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

###  Alternatives

[wi1dcard/china-divisions

中国行政区划地址库 SDK + 爬虫 + 数据。

2204.1k1](/packages/wi1dcard-china-divisions)

PHPackages © 2026

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