Build Tar file from directory in PHP without exec/passthru
PHP 5.3 offers a much easier way to solve this issue.
Look here: http://www.php.net/manual/en/phardata.buildfromdirectory.php
<?php$phar = new PharData('project.tar');// add all files in the project$phar->buildFromDirectory(dirname(__FILE__) . '/project');?>
At http://pear.php.net/package/Archive_Tar you can donload the PEAR tar package and use it like this to create the archive:
<?phprequire 'Archive/Tar.php';$obj = new Archive_Tar('archive.tar');$path = '/path/to/folder/';$handle=opendir($path); $files = array();while(false!==($file = readdir($handle))) { $files[] = $path . $file; }if ($obj->create($files)) { //Sucess }else { //Fail }?>