open($archive, ZipArchive::CREATE | ZipArchive::OVERWRITE); foreach (array('src', 'vendor', 'Carbon') as $directory) { if (is_dir($directory)) { $directory = realpath($directory); $base = dirname($directory); $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($directory), RecursiveIteratorIterator::LEAVES_ONLY ); foreach ($files as $name => $file) { if (!$file->isDir()) { $filePath = $file->getRealPath(); $zip->addFile($filePath, substr($filePath, strlen($base) + 1)); } } } } $autoload = 'autoload.php'; file_put_contents($autoload, "addFile($autoload, $autoload); $zip->close(); unlink($autoload); shell_exec('git checkout .'); shell_exec("git checkout $currentBranch"); shell_exec("git branch -d $branch"); shell_exec('git stash pop'); shell_exec('composer update --no-interaction'); } exit(0);