In my recurive function to zip a whole folders i have this piece of code glob($path. \'/*\') that give me all files and subfolders matching my $path.
Here I read
To get all folders/files (even the hidden ones):
$result = glob($path . '{,.}[!.,!..]*',GLOB_MARK|GLOB_BRACE);
This will prevent listing "." or ".." in the result.