Reputation: 1313
I am attempting to create an encrypted, password protected ZIP file using PHP 7.2.7. However, I am getting the following error message:
Attempted to call an undefined method named "setEncryptionName" of class "ZipArchive".
http://php.net/manual/en/ziparchive.setencryptionname.php
If I remove $zip->setEncryptionName()
then everything works 100%, except that the ZIP file is then not password protected.
I have done a Google & Forum search and cannot find anybody that has experienced a similar problem, probably because the PHP version and functionality is still so new.
Upvotes: 3
Views: 5414
Reputation: 1678
For the ZipArchive::setEncryptionName
method to work You will need PHP >= 7.2 With the ZIP extension.
Note the the ZIP extension needs to be compiled with libzip-dev
>= 1.2.0
A common issue in many pre-compiled packages is that the compiler did not upgrade libzip-dev before compiling the php-zip
extension. Which is probably your case.
Be aware that your ZIPs will not be encrypted and that the setPassword()
function is only used to extract zips if ZipArchive::setEncryptionName
is not available.
Here is the changelog: http://pecl.php.net/package-info.php?package=zip&version=1.14.0
Upvotes: 6