Using Phar Archives: the Phar and PharData classThe Phar class supports reading and manipulation of Phar archives, as well as iteration through inherited functionality of the RecursiveDirectoryIterator class. With support for the ArrayAccess interface, files inside a Phar archive can be accessed as if they were part of an associative array.
The PharData class extends the Phar, and
allows creating and modifying non-executable (data) tar and zip archives even if
It is important to note that when creating a Phar archive, the full path should be passed to the Phar object constructor. Relative paths will fail to initialize.
Assuming that
An empty Phar archive will be created at
With the newly created
In addition, the Phar object is the only way to access Phar-specific metadata, through Phar::getMetadata, and the only way to set or retrieve a Phar archive's PHP loader stub through Phar::getStub and Phar::setStub. Additionally, compression for the entire Phar archive at once can only be manipulated using the Phar class. The full list of Phar object functionality is documented below. The PharFileInfo class extends the SplFileInfo class, and adds several methods for manipulating Phar-specific details of a file contained within a Phar, such as manipulating compression and metadata. |