
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
PHP Phar context options
Introduction
Phar stands for PHP Archive. All the resources of a certain PHP application or library are packages in a single .phar file for the purpose of istribution. A phar file can be used as IO stream with phar:// wrapper. Context options for phar:// wrapper are listed as follows −
compress
PHP has following predefined constants for defining compression formats
Constant | Value | Description | |
---|---|---|---|
Phar::NONE | 0x00000000 | no compression | |
Phar::COMPRESSED | 0x0000F000 | bitmask with file flags to determine if any compression is presen | |
Phar::GZ | 0x00001000 | zlib (gzip) compression | |
Phar::BZ2 | 0x00002000 | bzip2 compression |
metadata
Any PHP variable containing information to store that describes the phar archive is used as argument for Phar::setMetadata() method
Example
This example Phar context option set for creating Phar file
<?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); ?>
- Related Articles
- PHP FTP context options
- PHP HTTP context options
- PHP MongoDB context options
- PHP Socket context options
- PHP SSL context options
- PHP Zip context options
- CURL context options in PHP
- PHP phar://
- PHP Context Parameters
- Python Context Variables
- Perl Variable Context
- Python Context Manager Types
- Context api in React.js
- Context API in ReactJS
- What is Context on Android?

Advertisements