src/MakeZip.php
public static function zipDir($sourcePath, $outZipPath, $deleteOriginal = false)
    {
        $pathInfo = pathInfo($sourcePath);
        $parentPath = $pathInfo['dirname'];
        $dirName = $pathInfo['basename'];

        $z = new ZipArchive();

        $ret = $z->open($outZipPath, ZipArchive::OVERWRITE);
        if ($ret === ZipArchive::ER_NOENT)
            $z->open($outZipPath, ZipArchive::CREATE);
        elseif ($ret !== ZipArchive::ER_MULTIDISK) return self::zipStatusString($ret);

        $z->addEmptyDir($dirName);
        self::folderToZip($sourcePath, $z, strlen("$parentPath/"));
        $z->close();

        self::delTree($sourcePath, $deleteOriginal);
    }
public static function zipDir($sourcePath, $outZipPath, $deleteOriginal = false)
    {
        $pathInfo = pathInfo($sourcePath);
        $parentPath = $pathInfo['dirname'];
        $dirName = $pathInfo['basename'];

        $z = new ZipArchive();

        $ret = $z->open($outZipPath, ZipArchive::OVERWRITE);
        if ($ret === ZipArchive::ER_NOENT)
            $z->open($outZipPath, ZipArchive::CREATE);
        elseif ($ret !== ZipArchive::ER_MULTIDISK) return self::zipStatusString($ret);

        $z->addEmptyDir($dirName);
        self::folderToZip($sourcePath, $z, strlen("$parentPath/"));
        $z->close();

        self::delTree($sourcePath, $deleteOriginal);
    }
Zip a folder (include itself).
Usage:
HZip::zipDir('/path/to/sourceDir', '/path/to/out.zip');

@param string $sourcePath Path of directory to be zip.
@param string $outZipPath Path of output zip file.
@param bool $deleteOriginal Deleta a pasta original, default false
@return mixed