命令行zip(wamp / windows / php)

I'm new to php and S.O community.

I'm on : -Windows -Wamp

My problem recently is to make a password protected zip for download. As you know, Ziparchive doesn't allow to make password protected zip, function setpassword is just for decryption.

So I heard I could do that by command line, but to be honest all I understand about exec() in command line is that php will execute zip.exe and password protect file.

So please what's the steps for making this "command line" work in my case (windows/wamp) ?

Here is my script :

<?php
$ZipN='zip.zip';
$Zip = new ZipArchive();
//File path
$file_path=$_SERVER['DOCUMENT_ROOT'].'/PF/';


function zipFilesAndDownload($ZipN,$Zip,$file_path){
    if ($Zip->open($ZipN, ZIPARCHIVE::CREATE )!==TRUE) {
        exit("cannot open <$ZipN>
");
    }
$Zip->addFromString("testfilephp.txt", "#1 This is a test string added as testfilephp.txt.
");
$Zip->close();

//Password protect Not working !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
exec("zip -P password $file_path.$ZipN $ZipN");

    //then send the headers to foce download the Zip file
    header("Content-type: application/zip"); 
    header("Content-Disposition: attachment; filename=$ZipN");
    header("Content-length: " . filesize($ZipN));
    header("Pragma: no-cache"); 
    header("Expires: 0"); 
    readfile("$ZipN");

    // Delete the files from the server, even if the user cancels the download
    ignore_user_abort(true);

    unlink($file_path.$ZipN);
    exit;
}

zipFilesAndDownload($ZipN,$Zip,$file_path);
?>

Thanks

7-zip has an amazing command-line based zip utility that supports passwords (-p switch). Get it here (get the Extra version for the standalone commandline). Here are some examples of its command-line usage.