The Phar class

Introduction

The Phar class provides a high-level interface to accessing and creating phar archives.

Class synopsis

Phar
extends RecursiveDirectoryIterator
implements Countable ArrayAccess
/* Inherited constants */
public const int FilesystemIterator::CURRENT_MODE_MASK;
public const int FilesystemIterator::CURRENT_AS_PATHNAME;
public const int FilesystemIterator::CURRENT_AS_FILEINFO;
public const int FilesystemIterator::CURRENT_AS_SELF;
public const int FilesystemIterator::KEY_MODE_MASK;
public const int FilesystemIterator::KEY_AS_PATHNAME;
public const int FilesystemIterator::FOLLOW_SYMLINKS;
public const int FilesystemIterator::KEY_AS_FILENAME;
public const int FilesystemIterator::NEW_CURRENT_AND_KEY;
public const int FilesystemIterator::OTHER_MODE_MASK;
public const int FilesystemIterator::SKIP_DOTS;
public const int FilesystemIterator::UNIX_PATHS;
/* Constants */
const int Phar::BZ2;
const int Phar::GZ;
const int Phar::NONE;
const int Phar::PHAR;
const int Phar::TAR;
const int Phar::ZIP;
const int Phar::COMPRESSED;
const int Phar::PHP;
const int Phar::PHPS;
const int Phar::MD5;
const int Phar::OPENSSL;
const int Phar::OPENSSL_SHA256;
const int Phar::OPENSSL_SHA512;
const int Phar::SHA1;
const int Phar::SHA256;
const int Phar::SHA512;
/* Methods */
public Phar::__construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS, stringnull $alias = null)
public void Phar::addEmptyDir(string $directory)
public void Phar::addFile(string $filename, stringnull $localName = null)
public void Phar::addFromString(string $localName, string $contents)
final public static string Phar::apiVersion()
public array Phar::buildFromDirectory(string $directory, string $pattern = "")
public array Phar::buildFromIterator(Traversable $iterator, stringnull $baseDirectory = null)
final public static bool Phar::canCompress(int $compression = 0)
final public static bool Phar::canWrite()
public Pharnull Phar::compress(int $compression, stringnull $extension = null)
public void Phar::compressFiles(int $compression)
public PharDatanull Phar::convertToData(intnull $format = null, intnull $compression = null, stringnull $extension = null)
public Pharnull Phar::convertToExecutable(intnull $format = null, intnull $compression = null, stringnull $extension = null)
public bool Phar::copy(string $from, string $to)
public int Phar::count(int $mode = COUNT_NORMAL)
final public static string Phar::createDefaultStub(stringnull $index = null, stringnull $webIndex = null)
public Pharnull Phar::decompress(stringnull $extension = null)
public bool Phar::decompressFiles()
public bool Phar::delMetadata()
public bool Phar::delete(string $localName)
public bool Phar::extractTo(string $directory, arraystringnull $files = null, bool $overwrite = false)
public stringnull Phar::getAlias()
public mixed Phar::getMetadata(array $unserializeOptions = [])
public bool Phar::getModified()
public string Phar::getPath()
public arrayfalse Phar::getSignature()
public string Phar::getStub()
final public static array Phar::getSupportedCompression()
final public static array Phar::getSupportedSignatures()
public string Phar::getVersion()
public bool Phar::hasMetadata()
final public static void Phar::interceptFileFuncs()
public bool Phar::isBuffering()
public intfalse Phar::isCompressed()
public bool Phar::isFileFormat(int $format)
final public static bool Phar::isValidPharFilename(string $filename, bool $executable = true)
public bool Phar::isWritable()
final public static bool Phar::loadPhar(string $filename, stringnull $alias = null)
final public static bool Phar::mapPhar(stringnull $alias = null, int $offset = 0)
final public static void Phar::mount(string $pharPath, string $externalPath)
final public static void Phar::mungServer(array $variables)
public bool Phar::offsetExists(string $localName)
public SplFileInfo Phar::offsetGet(string $localName)
public void Phar::offsetSet(string $localName, resourcestring $value)
public void Phar::offsetUnset(string $localName)
final public static string Phar::running(bool $returnPhar = true)
public true Phar::setAlias(string $alias)
public true Phar::setDefaultStub(stringnull $index = null, stringnull $webIndex = null)
public void Phar::setMetadata(mixed $metadata)
public void Phar::setSignatureAlgorithm(int $algo, stringnull $privateKey = null)
public bool Phar::setStub(resourcestring $stub, int $length = -1)
public void Phar::startBuffering()
public void Phar::stopBuffering()
final public static bool Phar::unlinkArchive(string $filename)
final public static void Phar::webPhar(
    stringnull $alias = null,
    stringnull $index = null,
    stringnull $fileNotFoundScript = null,
    array $mimeTypes = [],
    callablenull $rewrite = null
)
public Phar::__destruct()
/* Inherited methods */
public RecursiveDirectoryIterator getChildren()
public string getSubPath()
public string getSubPathname()
public bool hasChildren(bool $allowLinks = false)
public string key()
public void next()
public void rewind()
public stringSplFileInfoFilesystemIterator FilesystemIterator::current()
public int FilesystemIterator::getFlags()
public string FilesystemIterator::key()
public void FilesystemIterator::next()
public void FilesystemIterator::rewind()
public void FilesystemIterator::setFlags(int $flags)
public mixed DirectoryIterator::current()
public string DirectoryIterator::getBasename(string $suffix = "")
public string DirectoryIterator::getExtension()
public string DirectoryIterator::getFilename()
public bool DirectoryIterator::isDot()
public mixed DirectoryIterator::key()
public void DirectoryIterator::next()
public void DirectoryIterator::rewind()
public void DirectoryIterator::seek(int $offset)
public string DirectoryIterator::__toString()
public bool DirectoryIterator::valid()
public intfalse SplFileInfo::getATime()
public string SplFileInfo::getBasename(string $suffix = "")
public intfalse SplFileInfo::getCTime()
public string SplFileInfo::getExtension()
public SplFileInfo SplFileInfo::getFileInfo(stringnull $class = null)
public string SplFileInfo::getFilename()
public intfalse SplFileInfo::getGroup()
public intfalse SplFileInfo::getInode()
public stringfalse SplFileInfo::getLinkTarget()
public intfalse SplFileInfo::getMTime()
public intfalse SplFileInfo::getOwner()
public string SplFileInfo::getPath()
public SplFileInfonull SplFileInfo::getPathInfo(stringnull $class = null)
public string SplFileInfo::getPathname()
public intfalse SplFileInfo::getPerms()
public stringfalse SplFileInfo::getRealPath()
public intfalse SplFileInfo::getSize()
public stringfalse SplFileInfo::getType()
public bool SplFileInfo::isDir()
public bool SplFileInfo::isExecutable()
public bool SplFileInfo::isFile()
public bool SplFileInfo::isLink()
public bool SplFileInfo::isReadable()
public bool SplFileInfo::isWritable()
public SplFileObject SplFileInfo::openFile(string $mode = "r", bool $useIncludePath = false, resourcenull $context = null)
public void SplFileInfo::setFileClass(string $class = SplFileObject::class)
public void SplFileInfo::setInfoClass(string $class = SplFileInfo::class)
public string SplFileInfo::__toString()

Changelog

Version Description
8.4.0 Added support for the Unix timestamp extension for Zip-based archives.
Table of Contents