Phpword refuses to work when creating a file based on a template. Produces errors

Warning: ZipArchive :: getFromName (): Invalid or uninitialized Zip object in C: \ xampp \ htdocs \ db \ phpword \ PhpWord \ Shared \ ZipArchive.php on line 200

Warning: ZipArchive :: getFromName (): Invalid or uninitialized Zip object in C: \ xampp \ htdocs \ db \ phpword \ PhpWord \ Shared \ ZipArchive.php on line 203

Warning: ZipArchive :: close (): Invalid or uninitialized Zip object in C: \ xampp \ htdocs \ db \ phpword \ PhpWord \ Shared \ ZipArchive.php on line 162

Fatal error: in C: \ xampp \ htdocs \ db \ phpword \ PhpWord \ Shared \ ZipArchive.php on line 163

Although if you call information about php, it is indicated that the zip is installed and working. With file permissions, everything is fine too - deleted all permissions and gave full access to the "Everything" group to the entire folder and subfolders with files.

Please help me figure it out. By the way, there is a machine at work (Linux, apache, php), so everything works there.

Script code for example (errors are presented above)

<?php //Начинаем работу с шаблоном require_once 'PhpWord/Autoloader.php'; \PhpOffice\PhpWord\Autoloader::register(); $phpWord = new \PhpOffice\PhpWord\PhpWord(); $tamplate=1; $template_path="templates/passport/passport".$tamplate.".docx"; //Путь к файлу-шаблону $document_name="passport.docx"; //Имя, под готорым файл будет сохранён на диск + под которым будут скачивать $save_path="saves/passport/"; //Куда сохранять $template = $phpWord->loadTemplate(realpath($template_path)); //Загружаем шаблон //Поиск-Замена $FIO='Александров Вадим Вадимович'; $template->setValue('FIO', $FIO); //Сохраняем $file =$save_path.$document_name; $template->saveAS($file); //Сохраняем документ ?> 
  • can download script - L. Vadim
  • @ L.Vadim, supplemented the question - n.osennij

0