Replies: 2   Views: 133
Error while trying to open the (base) template as a zip file

Posted by tangamampilia  · 07-07-2023 - 16:21


I'm considering purchasing PHPDocx due the lack of support of a open source library. For the evaluation I downloaded the trial version and tried the following:

$path = app_path('/cfiles/TemplateBlocks_symbols.docx');
if (!file_exists($path)) {
        echo 'File doesn\'t exists';
if (!extension_loaded('zip')) { 
        echo 'No zip extension available';
$docs = new \CreateDocxFromTemplate($path);


As you can see, I'm verifiying both the file path and the zip extension enabled. Also I added one of the sample files, but the script keep poping the error "Error while trying to open the (base) template as a zip file". Not sure if there anything else I can do. The PHP version is 8.

Can you help me? Basically I'm interested in the "list" feature.



Posted by admin  · 07-07-2023 - 18:10


That error appears when phpdocx can't open the DOCX file to be used as template, can't read the base template available in the templates folder of the package or it isn't a valid DOCX file (a DOCX is a ZIP file). Please check the path you are using is correct and PHP has read access, you have copied all phpdocx files and PHP can read them, and the DOCX is correct and valid.

We also recommend you check and run the sample included in the package (examples folder) using the PHP CLI mode. phpdocx 14 is compatible with all PHP versions from PHP 5.6 to PHP 8.2.


Posted by uncontested  · 18-07-2023 - 17:25

Thanks. I purchased the library (this this account) and I could notice I need to update a path in the phpdocxconfig.ini so now it's working.