@Comeodore

Как решить ошибку PHP Word?

Здраствуйте, по данному пути
public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/

Находятся такие файлы:
5f62176d92150034316111.png
Использую такой код:
require_once 'vendor/autoload.php';
	$document = new \PhpOffice\PhpWord\TemplateProcessor('resources/Template.docx');
	$document->setValue('FirstName', '777');
	$document->saveAs('resources/result.docx');

resources:
5f621775aba6d737358246.png
Вылетает такая ошибка в error_log:
[16-Sep-2020 13:41:22 UTC] PHP Warning: copy(resources/Template.docx): failed to open stream: No such file or directory in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php on line 111
[16-Sep-2020 13:41:22 UTC] PHP Fatal error: Uncaught PhpOffice\PhpWord\Exception\CopyFileException: Could not copy 'resources/Template.docx' file to '/tmp/PhpWordSqAGl2'. in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php:112
Stack trace:
#0 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-content/themes/zakra/page.php(38): PhpOffice\PhpWord\TemplateProcessor->__construct('resources/Templ...')
#1 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-includes/template-loader.php(106): include('/home/tefpklwa2...')
#2 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-blog-header.php(19): require_once('/home/tefpklwa2...')
#3 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/index.php(17): require('/home/tefpklwa2...')
#4 {main}
thrown in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php on line 112

Проверил все пути, переустановил phpword, ничего не помогает, помогите пожалуйста, заранее благодарен всем откликнувшимся.
  • Вопрос задан
  • 849 просмотров
Решения вопроса 1
@Comeodore Автор вопроса
Прописал полностью путь, но возникла новая ошибка
[16-Sep-2020 20:09:44 UTC] PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/Shared/ZipArchive.php:135
Stack trace:
#0 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/TemplateProcessor.php(117): PhpOffice\PhpWord\Shared\ZipArchive->open('/tmp/PhpWord57H...')
#1 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-content/themes/zakra/page.php(38): PhpOffice\PhpWord\TemplateProcessor->__construct('/home/tefpklwa2...')
#2 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-includes/template-loader.php(106): include('/home/tefpklwa2...')
#3 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-blog-header.php(19): require_once('/home/tefpklwa2...')
#4 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/index.php(17): require('/home/tefpklwa2...')
#5 {main}
thrown in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/Shared/ZipArchive.php on line 135


Попробовал поменять код, теперь такая ошибка
Код:
require_once '/home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/autoload.php';
	$templateProcessor = new TemplateProcessor('/home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/resources/Template.docx');
	$templateProcessor->setValue('FirstName', '777');
	$templateProcessor->saveAs('/home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/vendor/phpoffice/phpword/src/PhpWord/resources/Result.docx');

Ошибка:

[16-Sep-2020 22:56:28 UTC] PHP Fatal error: Uncaught Error: Class 'TemplateProcessor' not found in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-content/themes/zakra/page.php:38
Stack trace:
#0 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-includes/template-loader.php(106): include()
#1 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-blog-header.php(19): require_once('/home/tefpklwa2...')
#2 /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/index.php(17): require('/home/tefpklwa2...')
#3 {main}
thrown in /home/tefpklwa2kwr/public_html/jaxx.dr-weedy.care/wp-content/themes/zakra/page.php on line 38
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы