src/Gzip.php
public static function compressFile($filepathSrc, $filepathDst = null, $level = 9)
	{
	    if (!isset($filepathDst)) {
	    	$filepathDst = $filepathSrc.'.gz';
	    }
	    $return = $filepathDst;
	    $mode = 'wb'.$level;
	    if ($fpOut = gzopen($filepathDst, $mode)) {
	        if ($fpIn = fopen($filepathSrc, 'rb')) {
	            while (!feof($fpIn)) {
	                gzwrite($fpOut, fread($fpIn, 1024*512));
	            }
	            fclose($fpIn);
	        } else {
	        	$return = false;
	        }
	        gzclose($fpOut);
	    } else {
	    	$return = false;
	    }
    	return $return;
	}
public static function compressFile($filepathSrc, $filepathDst = null, $level = 9)
	{
	    if (!isset($filepathDst)) {
	    	$filepathDst = $filepathSrc.'.gz';
	    }
	    $return = $filepathDst;
	    $mode = 'wb'.$level;
	    if ($fpOut = gzopen($filepathDst, $mode)) {
	        if ($fpIn = fopen($filepathSrc, 'rb')) {
	            while (!feof($fpIn)) {
	                gzwrite($fpOut, fread($fpIn, 1024*512));
	            }
	            fclose($fpIn);
	        } else {
	        	$return = false;
	        }
	        gzclose($fpOut);
	    } else {
	    	$return = false;
	    }
    	return $return;
	}
public static function compressFile ( $ filepathSrc , $ filepathDst = null , $ level = 9 ) { if ( ! isset ( $ filepathDst ) ) { $ filepathDst = $ filepathSrc . '.gz' ; } $ return = $ filepathDst ; $ mode = 'wb' . $ level ; if ( $ fpOut = gzopen ( $ filepathDst , $ mode ) ) { if ( $ fpIn = fopen ( $ filepathSrc , 'rb' ) ) { while ( ! feof ( $ fpIn ) ) { gzwrite ( $ fpOut , fread ( $ fpIn , 1024 * 512 ) ) ; } fclose ( $ fpIn ) ; } else { $ return = false ; } gzclose ( $ fpOut ) ; } else { $ return = false ; } return $ return ; }
Compress a file
Removes original

@param string  $filepathSrc input file
@param string  $filepathDst optional output file (optional)
@param integer $level       compression level (optional)

@return string|false
Compress a file Removes original