I downloaded the PHPWord library and so far I am quite happy with the results I guess - unless that I can't save a document properly - it does save the document but its empty.
This is my code:
preg_match_all("/\.(?!.*\.)(.+)/", $word_document, $mime);
$mime = $mime[0][0]; // contains ".docx" now
$templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($word_document);
// $word_document contains the absolute path to the doc
$templateProcessor->setValue('PLACEHOLDER', 'Doe');
// ${PLACEHOLDER} in doc is replaced with "Doe"
var_dump($templateProcessor);
/* returns, among others, ["tempDocumentMainPart":protected]=>
string(836) "Behördenvollmacht für Doe" -> you can see that 'Doe' is now contained in the
document. */
$templateProcessor->saveAs($path.$new_doc_name.$mime); // saves the document but its empty
Any tips or ideas why this is not working properly?