Head-to-head comparison of Phar, Tar and Zip

What are the good and the bad things about the three supported file formats in the phar extension? This table attempts to address that question.

Feature matrix: Phar vs. Tar vs. Zip
FeaturePharTarZip
Standard File FormatNoYesYes
Can be executed without the Phar Extension [1]YesNoNo
Per-file compressionYesNoYes
Whole-archive compressionYesYesNo
Whole-archive signature validationYesYesYes
Web-specific application supportYesYesYes
Per-file Meta-dataYesYesYes
Whole-Archive Meta-dataYesYesYes
Archive creation/modification [2]YesYesYes
Full support for all stream wrapper functionsYesYesYes
Can be created/modified even if phar.readonly=1 [3]NoYesYes

Tip

[1] PHP can only directly access the contents of a Phar archive without the Phar extension if it is using a stub that extracts the contents of the phar archive. The stub created by Phar::createDefaultStub() extracts the phar archive and runs its contents from a temporary directory if no phar extension is found.

Tip

[2] All write access requires phar.readonly to be disabled in php.ini or on the command-line directly.

Tip

[3] Only tar and zip archives without .phar in their filename and without an executable stub .phar/stub.php can be created if phar.readonly=1.

To Top