如何在PHP中使用受密码保护的zip文件创建我的目录备份?

I want to create a weekly backup of my project directory in PHP. I need help to create a password protected zip file in php. I use the below function, but that not create a whole folder backup as well as not helping for password protected.

    $path = realpath('');
    $files = glob($path.'*');
    $files = $files[0];
    $password = "test';
    @system('zip -P $password'.$filename.' '.$files);

Using zip command you can try the following.

<?php 
   $path = realpath('');
   $password = "test";
   $zipFileName = "file.zip";
   exec ("zip -r -P {$password} {$zipFileName} {$path}");
?>

-r is added to add all the files recursively.

You can use function system() or exec() to execute the command.

See this post https://unix.stackexchange.com/questions/57013/zip-all-files-in-directory