@Nentra

PHPWord — почему не работает сохранение в word файл?

Есть плагин PHPWord
https://github.com/PHPOffice/PHPWord

У меня при сохранении в файл
$objWriter->save('helloWorld.docx');

Сайт падает в ошибку
скрин
https://disk.yandex.ru/i/D7_PouJ-u-ETnw

Если убрать строчку $objWriter->save('helloWorld.docx'); то сайт в ошибку не падает.
сам объект приходит:

код
// Saving the document as OOXML file...
$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');


Вывод (отрывок):
Template objWriter: object(PhpOffice\PhpWord\Writer\Word2007)#27 (11) {
["contentTypes":"PhpOffice\PhpWord\Writer\Word2007":private]=>
array(2) {
["default"]=>
array(0) {
}
["override"]=>
array(0) {
}
}
["relationships":"PhpOffice\PhpWord\Writer\Word2007":private]=>
array(0) {
}
["phpWord":protected]=>
object(PhpOffice\PhpWord\PhpWord)#3 (3) {
["sections":"PhpOffice\PhpWord\PhpWord":private]=>
array(1) {
[0]=>
object(PhpOffice\PhpWord\Element\Section)#12 (21) {
["container":protected]=>
string(7) "Section"
["style":"PhpOffice\PhpWord\Element\Section":private]=>
object(PhpOffice\PhpWord\Style\Section)#13 (33) {
["orientation":"PhpOffice\PhpWord\Style\Section":private]=>
string(8) "portrait"
["paper":"PhpOffice\PhpWord\Style\Section":private]=>
object(PhpOffice\PhpWord\Style\Paper)#14 (8) {
["sizes":"PhpOffice\PhpWord\Style\Paper":private]=>
array(7) {
["A3"]=>
array(3) {
[0]=>
int(297)
[1]=>
int(420)
[2]=>
string(2) "mm"
}
["A4"]=>
array(3) {
[0]=>
int(210)
[1]=>
int(297)
[2]=>
string(2) "mm"
}
["A5"]=>
array(3) {
[0]=>
int(148)
[1]=>
int(210)
[2]=>
string(2) "mm"
}
["B5"]=>
array(3) {
[0]=>
int(176)
[1]=>
int(250)
[2]=>
string(2) "mm"
}
["Folio"]=>
array(3) {
[0]=>
float(8.5)
[1]=>
int(13)
[2]=>
string(2) "in"
}
["Legal"]=>
array(3) {
[0]=>
float(8.5)
[1]=>
int(14)
[2]=>
string(2) "in"
}
["Letter"]=>
array(3) {
[0]=>
float(8.5)
[1]=>
int(11)
[2]=>
string(2) "in"
}
}
["size":"PhpOffice\PhpWord\Style\Paper":private]=>
string(2) "A4"
["width":"PhpOffice\PhpWord\Style\Paper":private]=>
float(11905.511811024)
["height":"PhpOffice\PhpWord\Style\Paper":private]=>
float(16837.795275591)
["styleName":protected]=>
NULL
["index":protected]=>
NULL
["aliases":protected]=>
array(0) {
}
["isAuto":"PhpOffice\PhpWord\Style\AbstractStyle":private]=>
bool(false)
}
["pageSizeW":"PhpOffice\PhpWord\Style\Section":private]=>
float(11905.511811024)
["pageSizeH":"PhpOffice\PhpWord\Style\Section":private]=>
float(16837.795275591)
["marginTop":"PhpOffice\PhpWord\Style\Section":private]=>
int(1440)
["marginLeft":"PhpOffice\PhpWord\Style\Section":private]=>
int(1440)
["marginRight":"PhpOffice\PhpWord\Style\Section":private]=>
int(1440)
["marginBottom":"PhpOffice\PhpWord\Style\Section":private]=>
int(1440)
["gutter":"PhpOffice\PhpWord\Style\Section":private]=>
int(0)
["headerHeight":"PhpOffice\PhpWord\Style\Section":private]=>
int(720)
["footerHeight":"PhpOffice\PhpWord\Style\Section":private]=>
int(720)
["pageNumberingStart":"PhpOffice\PhpWord\Style\Section":private]=>
NULL
["colsNum":"PhpOffice\PhpWord\Style\Section":private]=>
int(1)
["colsSpace":"PhpOffice\PhpWord\Style\Section":private]=>
int(720)
["breakType":"PhpOffice\PhpWord\Style\Section":private]=>
NULL
["lineNumbering":"PhpOffice\PhpWord\Style\Section":private]=>
NULL
["vAlign":"PhpOffice\PhpWord\Style\Section":private]=>
NULL
["borderTopSize":protected]=>
NULL
["borderTopColor":protected]=>
NULL
.......


Почему это происходит?
Как сохранить данные в файл word?
  • Вопрос задан
  • 253 просмотра
Решения вопроса 1
@Nentra Автор вопроса
Всем спасибо, действительно нужно было логи посмотреть, в моём случае логи апача
(у меня битрикс)
/var/log/httpd/error_log.

Проблема была с xmlwriter, дописал в файл

/etc/php.d/20-xmlwriter.ini


Enable xmlwriter extension module
extension=xmlwriter.so


Перезагрузил апач и всё заработало.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
SilenceOfWinter
@SilenceOfWinter Куратор тега PHP
та еще зажигалка...
попробуй вместо своего кода базовый пример и как тебе уже сказали смотри ошибки в логах
Ответ написан
Ваш ответ на вопрос

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

Войти через центр авторизации
Похожие вопросы