So here is my code:
<?php
$zip = new ZipArchive;
if ($zip->open('test.docx') === TRUE) {
$xmlString = $zip->getFromName('word/document.xml');
$xmlString = str_replace('$FIRST_AND_LAST_NAME', 'John Doe', $xmlString);
$zip->addFromString('word/document.xml', $xmlString);
echo 'ok';
$zip->close();
} else {
echo 'failed';
}
Its purpose is simple. It opens a test.docx file, searches for all occurences of a string "$FIRST_AND_LAST_NAME" and replaces them with "John Doe".
It works perfectly on my Windows development server (the "John Doe" string is in the docuemnt when I open it).
It does not work on my Lunux production server ("$FIRST_AND_LAST_NAME" string is still there, there is no "John Doe").
There is no error or notice, the "ok" is printed without any errors. I made sure the test.docx file has priviledges set to 777.