Forum


Replies: 4   Views: 738
Warning ini file
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by fs@baysense.com  · 23-10-2022 - 07:11

the following code generates a warning in php 8.1.11:

$docx = new CreateDocxFromTemplate($template_url);

$docx->createDocx($docx_url);

 

<b>Warning</b>:  Undefined array key "settings" in <b>/var/www/xxx.com/public_html/includes/phpdocx/classes/CreateDocx.php</b> on line <b>5280</b><br />
<br />
<b>Warning</b>:  Trying to access array offset on value of type null in <b>/var/www/xxx.com/public_html/includes/phpdocx/classes/CreateDocx.php</b> on line <b>5280</b>

 

 

Posted by admin  · 23-10-2022 - 08:34

Hello,

We have tested in with PHP 8, PHP 8.1 and PHP 8.2 and no warning appears. 

Please check you have not commented all settings section in config/phpdocxconfig.ini or the file is missing in the phpdocx folder installation or the file has some wrong content that can't be parsed. The default content in this INI file is the following:

[settings]
; absolute path to the temp dir. If empty the default system tmp directory will be used
temp_path = ""

; if set to true: detects if the contents are UTF-8 encoded and if not encodes them
; if set to false do nothing
encode_to_UTF8 = "false"

; default document language
language = "en-US"

; default paper size
paper_size = "A4"

; right to left languages config
;bidi = "true"
;rtl = "true"

; if true, generate the DOCX as stream instead of saving it to the file system. Only available for Premium licenses
;stream="true"

[license]
; PHPDocX license code
code = ""
; subdomain (Basic license), domain (Advanced license) or IP (Premium license)
value = ""

[transform]
; transform options. Only available for Advanced and Premium licenses

; libreoffice, native, msword, openoffice
;method = "libreoffice"

; libreoffice installation path, absolute path
;path = "/opt/libreoffice/program/soffice"

; custom HOME folder; allows setting a custom HOME folder when doing the transformations using LibreOffice
;home_folder = ""

As you can check the settings key is set, including the encode_to_UTF8 key. The line you point out is the following:

if ($this->_phpdocxconfig['settings']['encode_to_UTF8'] == 'true'

_phpdocxconfig is an internal variable that contains config/phpdocxconfig.ini parsed. Please check you have not removed this required section in the file (or you have removed the whole file).

From your PHP information:

<b>Warning</b>:  Trying to access array offset on value of type null in

it seems the config/phpdocxconfig.ini file doesn't exist or it's not valid or it can't be readed.

Regards.

Posted by fs@baysense.com  · 24-10-2022 - 10:09

Deleted by fs@baysense.com · 24-10-2022 - 10:11

Posted by fs@baysense.com  · 24-10-2022 - 10:13

you are correct, I was missing the word [settings] at the top of the file

Posted by peteruser1  · 29-10-2022 - 16:37

Deleted by admin · 30-10-2022 - 08:19