TAR libraries for PHP
- PharData comes with PHP’s Phar extension, which is enabled by default. It builds archives from directories, adds files and strings, compresses to
.tar.gz/.tar.bz2, extracts, and lets you read entries throughphar://stream URLs. It keeps the archive index in memory and works best for small and medium archives. - php-archive (
splitbrain/php-archive) is pure PHP and reads and writes sequentially, so memory use stays low for large archives. It can create.tar,.tar.gzand.tar.bz2, list and extract with include/exclude patterns, but doesn’t modify existing archives.
Use PharData when you need no dependencies; use php-archive for large archives, or when the Phar extension is disabled on your host.
- PharData PharData is PHP's built-in class for TAR and .tar.gz archives. How to create a tar from a folder, add files, compress to .tar.gz, list and extract, with code.
- php-archive php-archive is a pure-PHP library to create and extract TAR, .tar.gz and .tar.bz2 files with low memory use. How to list, extract and create archives in PHP.