PHP code example of tyz910 / docx-templates
1. Go to this page and download the library: Download tyz910/docx-templates library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tyz910 / docx-templates example snippets
use DocxTemplate\TemplateFactory;
$template = TemplateFactory::load('template1.docx');
$template->assign([
'name' => 'Jon',
'surname' => 'Snow',
'house' => 'Stark'
]);
$template->save('jon.docx');
use DocxTemplate\TemplateFactory;
TemplateFactory::useMarkSyntax('${', '}'); // prefix and suffix
$template = TemplateFactory::load('template.docx');