alshabalin / docx-template
Docx Template
v1.0.4
2017-05-05 05:22 UTC
Requires
- php: >=5.4
- ext-zip: *
This package is not auto-updated.
Last update: 2024-11-10 02:53:03 UTC
README
Allows convert any docx document to template, using variable, like {this}
.
Install the package
composer require alshabalin/docx-template
How to use
<?php require 'vendor/autoload.php'; use Alshabalin\DocxTemplate\DocxTemplate as DocxTemplate; $data = [ 'key' => 'value', 'name' => 'John', 'lastname' => 'Doe', 'city' => 'London', ]; $template = new DocxTemplate(); $template->open('document.docx') ->setData($data) ->save('result.docx');
You may want to remove any missing variables from your template by passing true
as the second param to setData
method:
$template->setData($data, true);