Zip everything except one folder in directory

I am using PHP where I am trying to ZIP everything inside the folder except one folder called assets. I have tried this code below with a password for security :smile: but don’t know how I add the function which would be to ignore one folder called assets

    $dir = './../';
    $zip_file = "./backupfolder/";
    $rootPath = realpath($dir);
    $password = "123456";
    exec("zip -r -P {$password} {$zip_file} {$rootPath}");

//output: given all file in zip including assets
expect: ignore assets folder to zip

If there’s nothing in the zip documentation that tells you how to exclude a particular folder, why not do it in code? Use something like opendir() and readdir() to read through the path contents and just exclude whichever folders or files that you don’t want in the zip file.

ETA: a quick search for “zip exclude a folder” suggests that the -x parameter can be used to specify the folder that you want to exclude.

You may also want to exclude the folder called backupfolder. Backups of backups aren’t very useful.