Home > Article > Backend Development > PHP Phar context options
Phar stands for PHP Archive. All resources for a PHP application or library are packaged in a single .phar file for distribution. phar files are available as IO streams with the phar:// wrapper. The context options for the phar:// wrapper are as follows:
PHP has the following predefined constants to define the compression format
Constant | Value | Description | |
---|---|---|---|
0x00000000 | No compression | ||
0x0000F000 | Bit mask and file flags , used to determine if there is any compression | ||
0x00001000 | zlib (gzip) compression | ||
0x00002000 | bzip2 compression |
Phar::setMetadata() method
ExampleThis example sets the Phar context options used to create Phar files<?php $context = stream_context_create(array('phar' => array('compress' => Phar::GZ)), array('metadata' => array('user' => 'cellog'))); file_put_contents('phar://my.phar/somefile.php', 0, $context); ?>
The above is the detailed content of PHP Phar context options. For more information, please follow other related articles on the PHP Chinese website!