alshabalin/docx-template

Docx Template

Installs: 39

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/alshabalin/docx-template

v1.0.4 2017-05-05 05:22 UTC

This package is not auto-updated.

Last update: 2025-10-12 07:13:39 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);