src/File.php
private static function addToZip(string $sourcePath, ZipArchive $zipFile): void
	{
		$source = new SplFileInfo($sourcePath);
		$exclusiveLength = strlen(str_replace($source->getFilename(), '', $source->getRealPath()));

		if ($source->isReadable()) {
			if ($source->isDir()) {
				$zipFile->addEmptyDir($source->getFilename());

				foreach (Finder::findFiles('*')
							 ->from($sourcePath) as $file) {
					/* @var $file \SplFileObject */
					$filePath = $file->getRealPath();
					$localPath = substr($filePath, $exclusiveLength);

					if ($file->isDir()) {
						$zipFile->addEmptyDir($localPath);
					} else {
						$zipFile->addFile($filePath, $localPath);
					}
				}
			} else {
				$zipFile->addFile($source->getRealPath(), $source->getFilename());
			}
		}
	}
private static function addToZip(string $sourcePath, ZipArchive $zipFile): void
	{
		$source = new SplFileInfo($sourcePath);
		$exclusiveLength = strlen(str_replace($source->getFilename(), '', $source->getRealPath()));

		if ($source->isReadable()) {
			if ($source->isDir()) {
				$zipFile->addEmptyDir($source->getFilename());

				foreach (Finder::findFiles('*')
							 ->from($sourcePath) as $file) {
					/* @var $file \SplFileObject */
					$filePath = $file->getRealPath();
					$localPath = substr($filePath, $exclusiveLength);

					if ($file->isDir()) {
						$zipFile->addEmptyDir($localPath);
					} else {
						$zipFile->addFile($filePath, $localPath);
					}
				}
			} else {
				$zipFile->addFile($source->getRealPath(), $source->getFilename());
			}
		}
	}
Prida source do zipu
@param string $sourcePath
@param ZipArchive $zipFile