
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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); ?>
Advertisements