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
Feature Phar Tar Zip
Standard File Format No Yes Yes
Can be executed without the Phar Extension [1] Yes No No
Per-file compression Yes No Yes
Whole-archive compression Yes Yes No
Whole-archive signature validation Yes Yes Yes (PHP 5.3.1+)
Web-specific application support Yes Yes Yes
Per-file Meta-data Yes Yes Yes
Whole-Archive Meta-data Yes Yes Yes
Archive creation/modification [2] Yes Yes Yes
Full support for all stream wrapper functions Yes Yes Yes
Can be created/modified even if phar.readonly=1 [3] No Yes Yes

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.

相关文章
php phar convert a phar archive to a non executable tar or zip filephp what makes a phar a phar and not a tar or a zip? head to head comparison of phar tar and zipphp what makes a phar a phar and not a tar or a zip? global phar bitmapped flagsphp what makes a phar a phar and not a tar or a zip? ingredients of all phar archives independent of file formatphp what makes a phar a phar and not a tar or a zip? phar manifest file entry definitionphp what makes a phar a phar and not a tar or a zip? phar file formatphp phar what makes a phar a phar and not a tar or a zip?php what makes a phar a phar and not a tar or a zip? phar signature formatphp what makes a phar a phar and not a tar or a zip? phar file stubphp what makes a phar a phar and not a tar or a zip? tar based pharsphp what makes a phar a phar and not a tar or a zip? zip based pharsphp phar returns true if the phar archive is based on the tar/phar/zip file format depending on the parameterphp phardata add an empty directory to the tar/zip archivephp phardata add a file from the filesystem to the tar/zip archivephp phardata convert a phar archive to a non executable tar or zip filephp phardata convert a non executable tar/zip archive to an executable phar archivephp phardata delete a file within a tar/zip archivephp phardata extract the contents of a tar/zip archive to a directoryphp phardata returns true if the tar/zip archive can be modifiedphp phardata set the contents of a file within the tar/zip to those of an external file or string
关注编程学问公众号