PhpDocxTemplate is a PHP library, which uses docx files as Twig templates
Install PhpDocxTemplate, using Composer:
composer require bingo-soft/phpdocxtemplate
use PhpDocxTemplate\PhpDocxTemplate;
$doc = "./templates/template1.docx";
$template = new PhpDocxTemplate($doc);
$template->render(["one" => "1", "two" => "2", "three" => "3", "four" => "4"]);
$template->save("./documents/report.docx");
PhpDocxTemplate draws inspiration from python-docx-template and PhpWord libraries.
MIT