PHP code example of alshabalin / docx-template

1. Go to this page and download the library: Download alshabalin/docx-template 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/ */

    

alshabalin / docx-template example snippets




lshabalin\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');

$template->setData($data, true);