Okay, let's go and see that (It's non blocking but I hate notice :-) )
/**
*
* Adds directory contents recursively into a zip.
*
* @param string $dirName. The path to the dir to add.
*
* @param string $myZip. The zip where the contents of the dir should be added.
*
*/
private function recursiveInsert($myZip, $fileName, $basePath){
$length = strlen($basePath);
if(is_dir($fileName)){
$dirName = substr($fileName, $length);
$myZip->addEmptyDir($newName); // <=== HERE ! undefined $newName ... to be replaced by $dirName, isn't it ?? :-)
$contentsDir = scandir($fileName);
foreach($contentsDir as $element){
if($element != "." && $element !=".."){
$this->recursiveInsert($myZip, $fileName."/".$element, $basePath);
}
}
}else{
$newName = substr($fileName, $length + 1);
$myZip->addFile($fileName, $newName);
}
}