mklocke/docnamic
Composer 安装命令:
composer require mklocke/docnamic
包简介
The document template engine
关键字:
README 文档
README
Docnamic is a template engine for OpenDocument files (*.odt) based on PHP's DOM and ZIP extensions. My goal is to provide a simple document generation library whose templates can be easily created using standard WYSIWYG OpenDocument software. I am interested if this library is useful for anybody out there and i will appreciate any feedback on Github or via email.
Please note that the public API should not be considered stable yet.
I will add tests once i am sure about the internal class interfaces.
Requirements
- PHP 5.6 or later
- DOM extension
- ZIP extension
Installation
Install this library via composer.
$ composer require mklocke/docnamic
Usage
Have a look at the folder examples which contains examples of how the library should be used.
$renderer = new Renderer(); $renderer->loadTemplate('template.odt') ->setData(['foo' => 'bar']) ->render('result.odt');
Convert to PDF
The resulting OpenDocument files can be easily converted to PDF using the unoconv CLI tool on most linux distributions.
Installation on Ubuntu: sudo apt-get install unoconv
Convert a ODT file to PDF: unoconv -f pdf -o result.pdf result.odt
FAQ
-
Can i use barcodes or QR Codes?
Yes, you can by using barcode fonts in your document template. OpenDocument files can have embedded fonts. If you use LibreOffice for creating your document templates, read their help pages regarding Embedding Fonts
-
Can i use nested loops in my document template?
No, for now nested loops are not supported.
-
Can i use dynamic images?
No, dynamic images are not supported yet.
-
What about encodings?
As OpenDocument is a UTF-8-based XML file format, your data should be UTF-8 encoded as well ;)
-
What about i18n or l10n?
As this is a rather simple template engine, it has no notion of languages, countries or currencies. This has be taken care of the integrating application.
Inspired by
mklocke/docnamic 适用场景与选型建议
mklocke/docnamic 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 45.22k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「templating」 「odt」 「OpenDocument」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mklocke/docnamic 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mklocke/docnamic 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mklocke/docnamic 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
A Processor for Markup written in PHP. Allows extraction of Markup into a data structure, orchestrated nested manipulation of said structure, and output as (optimized) Markup.
Melis Platform Templating Plugin Creator
Serpent is a lightweight and compiling templating engine for PHP. It was designed to seamlessly integrate into existing MVC frameworks. It uses PHP itself as its template language, so you do not need to learn a new markup language. On the other side you get many improvements compared to pure PHP.
The template engine.
Template language for PHP
统计信息
- 总下载量: 45.22k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04