Phar
class Phar extends RecursiveDirectoryIterator implements RecursiveIterator, SeekableIterator, Countable, ArrayAccess (View source)
The Phar class provides a high-level interface to accessing and creating phar archives.
Constants
CURRENT_MODE_MASK |
|
CURRENT_AS_PATHNAME |
|
CURRENT_AS_FILEINFO |
|
CURRENT_AS_SELF |
|
KEY_MODE_MASK |
|
KEY_AS_PATHNAME |
|
FOLLOW_SYMLINKS |
|
KEY_AS_FILENAME |
|
NEW_CURRENT_AND_KEY |
|
SKIP_DOTS |
|
UNIX_PATHS |
|
OTHER_MODE_MASK |
|
BZ2 |
|
GZ |
|
NONE |
|
PHAR |
|
TAR |
|
ZIP |
|
COMPRESSED |
|
PHP |
|
PHPS |
|
MD5 |
|
OPENSSL |
|
SHA1 |
|
SHA256 |
|
SHA512 |
|
OPENSSL_SHA256 |
|
OPENSSL_SHA512 |
|
Methods
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Construct a Phar archive object
(Unknown)
Returns true if the phar archive can be modified
Gets an SplFileInfo object for the path
Gets an SplFileObject object for the file
Sets the class name used with SplFileInfo::openFile
Sets the class used with getFileInfo and getPathInfo
No description
Rewinds back to the beginning
Check whether current DirectoryIterator position is a valid file
Retrieve the key for the current file
The current file
Move to the next file
Seek to a DirectoryIterator item
Returns whether current entry is a directory and not '.' or '..'
Returns an iterator for the current entry if it is a directory
No description
(Unknown)
Add an empty directory to the phar archive
(Unknown)
Add a file from the filesystem to the phar archive
(Unknown)
Add a file from the filesystem to the phar archive
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a phar archive from the files within a directory.
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a phar archive from an iterator.
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses all files in the current Phar archive
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses all files in the current Phar archive
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses the entire Phar archive using Gzip or Bzip2 compression
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses the entire Phar archive
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Convert a phar archive to another executable phar archive file format
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Convert a phar archive to a non-executable tar or zip file
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Copy a file internal to the phar archive to another new file within the phar
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the number of entries (files) in the Phar archive
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Delete a file within a phar archive
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Deletes the global metadata of the phar
(Unknown)
Extract the contents of a phar archive to a directory
No description
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns phar archive meta-data
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return whether phar was modified
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return MD5/SHA1/SHA256/SHA512/OpenSSL signature of a Phar archive
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return the PHP loader or bootstrap stub of a Phar archive
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return version info of Phar archive
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns whether phar has global meta-data
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Used to determine whether Phar write operations are being buffered, or are flushing directly to disk
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Returns true if the phar archive is based on the tar/phar/zip file format depending on the parameter
(PHP >= 5.3.0, PECL phar >= 1.0.0)
determines whether a file exists in the phar
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Gets a PharFileInfo object for a specific file
(PHP >= 5.3.0, PECL phar >= 1.0.0)
set the contents of an internal file to those of an external file
(PHP >= 5.3.0, PECL phar >= 1.0.0)
remove a file from a phar
(PHP >= 5.3.0, PECL phar >= 1.2.1)
Set the alias for the Phar archive
(Unknown)
Used to set the PHP loader or bootstrap stub of a Phar archive to the default loader
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets phar archive meta-data
(PHP >= 5.3.0, PECL phar >= 1.1.0)
set the signature algorithm for a phar and apply it.
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Used to set the PHP loader or bootstrap stub of a Phar archive
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Start buffering Phar write operations, do not modify the Phar object on disk
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Stop buffering write requests to the Phar archive, and save changes to disk
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the api version
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether phar extension supports compression using either zlib or bzip2
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether phar extension supports writing and creating phars
(Unknown)
Create a phar-file format specific stub
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Return array of supported compression algorithms
(PHP >= 5.3.0, PECL phar >= 1.1.0)
Return array of supported signature types
(PHP >= 5.3.0, PECL phar >= 2.0.0)
instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns whether the given filename is a valid phar filename
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Loads any phar archive with an alias
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Reads the currently executed file (a phar) and registers its manifest
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Returns the full path on disk or full phar URL to the currently executing Phar archive
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Mount an external path or file to a virtual location within the phar archive
(Unknown)
Defines a list of up to 4 $_SERVER variables that should be modified for execution
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Completely remove a phar archive from disk and from memory
(PHP >= 5.3.0, PECL phar >= 2.0.0)
mapPhar for web-based phars. front controller for web applications
Details
__construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS, string $alias = null, $fileformat = null)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Construct a Phar archive object
string
getPath()
Gets the path without filename
string
getFilename()
Gets the filename
string
getExtension()
Gets the file extension
string
getBasename(string $suffix = '')
Gets the base name of the file
string
getPathname()
Gets the path to the file
int|false
getPerms()
Gets file permissions
int|false
getInode()
Gets the inode for the file
int|false
getSize()
Gets file size
int|false
getOwner()
Gets the owner of the file
int|false
getGroup()
Gets the file group
int|false
getATime()
Gets last access time of the file
int|false
getMTime()
Gets the last modified time
int|false
getCTime()
Gets the inode change time
string|false
getType()
Gets file type
bool
isWritable()
(Unknown)
Returns true if the phar archive can be modified
bool
isReadable()
Tells if file is readable
bool
isExecutable()
Tells if the file is executable
bool
isFile()
Tells if the object references a regular file
bool
isDir()
Tells if the file is a directory
bool
isLink()
Tells if the file is a link
string|false
getLinkTarget()
Gets the target of a link
string|false
getRealPath()
Gets absolute path to file
SplFileInfo
getFileInfo(T> $class = null)
Gets an SplFileInfo object for the file
SplFileInfo|null
getPathInfo(T> $class = null)
Gets an SplFileInfo object for the path
SplFileObject
openFile(string $mode = 'r', bool $useIncludePath = false, resource $context = null)
Gets an SplFileObject object for the file
void
setFileClass(T> $class = SplFileObject::class)
Sets the class name used with SplFileInfo::openFile
void
setInfoClass(T> $class = SplFileInfo::class)
Sets the class used with getFileInfo and getPathInfo
string
__toString()
Returns the path to the file as a string
void
_bad_state_ex()
No description
__wakeup()
No description
array
__debugInfo()
No description
bool
isDot()
Determine if current DirectoryIterator item is '.' or '..'
void
rewind()
Rewinds back to the beginning
bool
valid()
Check whether current DirectoryIterator position is a valid file
mixed
key()
Retrieve the key for the current file
mixed
current()
The current file
void
next()
Move to the next file
void
seek(int $position)
Seek to a DirectoryIterator item
int
getFlags()
Get the handling flags
void
setFlags(int $flags)
Sets handling flags
bool
hasChildren(bool $allow_links = false)
Returns whether current entry is a directory and not '.' or '..'
RecursiveIterator|null
getChildren()
Returns an iterator for the current entry if it is a directory
string
getSubPath()
Get sub path
string
getSubPathname()
Get sub path and name
__destruct()
No description
void
addEmptyDir(string $directory)
(Unknown)
Add an empty directory to the phar archive
void
addFile(string $filename, string $localName = null)
(Unknown)
Add a file from the filesystem to the phar archive
void
addFromString(string $localName, string $contents)
(Unknown)
Add a file from the filesystem to the phar archive
array
buildFromDirectory(string $directory, $pattern = '')
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a phar archive from the files within a directory.
array
buildFromIterator(Traversable $iterator, string $baseDirectory = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a phar archive from an iterator.
void
compressFiles(int $compression)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses all files in the current Phar archive
bool
decompressFiles()
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses all files in the current Phar archive
Phar|null
compress(int $compression, string $extension = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses the entire Phar archive using Gzip or Bzip2 compression
Phar|null
decompress(string $extension = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses the entire Phar archive
Phar|null
convertToExecutable(int $format = null, int $compression = null, string $extension = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Convert a phar archive to another executable phar archive file format
PharData|null
convertToData(int $format = null, int $compression = null, string $extension = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Convert a phar archive to a non-executable tar or zip file
bool
copy(string $to, string $from)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Copy a file internal to the phar archive to another new file within the phar
int
count(int $mode = COUNT_NORMAL)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the number of entries (files) in the Phar archive
bool
delete(string $localName)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Delete a file within a phar archive
bool
delMetadata()
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Deletes the global metadata of the phar
bool
extractTo(string $directory, string|array|null $files = null, bool $overwrite = false)
(Unknown)
Extract the contents of a phar archive to a directory
string|null
getAlias()
No description
mixed
getMetadata(array $unserializeOptions = [])
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns phar archive meta-data
bool
getModified()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return whether phar was modified
array|false
getSignature()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return MD5/SHA1/SHA256/SHA512/OpenSSL signature of a Phar archive
string
getStub()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return the PHP loader or bootstrap stub of a Phar archive
string
getVersion()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return version info of Phar archive
bool
hasMetadata()
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns whether phar has global meta-data
bool
isBuffering()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Used to determine whether Phar write operations are being buffered, or are flushing directly to disk
int|false
isCompressed()
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)
bool
isFileFormat(int $format)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Returns true if the phar archive is based on the tar/phar/zip file format depending on the parameter
bool
offsetExists(string $localName)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
determines whether a file exists in the phar
mixed
offsetGet(string $localName)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Gets a PharFileInfo object for a specific file
void
offsetSet(string $localName, TValue $value)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
set the contents of an internal file to those of an external file
void
offsetUnset(string $localName)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
remove a file from a phar
bool
setAlias(string $alias)
(PHP >= 5.3.0, PECL phar >= 1.2.1)
Set the alias for the Phar archive
bool
setDefaultStub(string $index = null, string $webIndex = null)
(Unknown)
Used to set the PHP loader or bootstrap stub of a Phar archive to the default loader
void
setMetadata(mixed $metadata)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets phar archive meta-data
void
setSignatureAlgorithm(int $algo, string $privateKey = null)
(PHP >= 5.3.0, PECL phar >= 1.1.0)
set the signature algorithm for a phar and apply it.
bool
setStub(string $stub, int $length)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Used to set the PHP loader or bootstrap stub of a Phar archive
void
startBuffering()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Start buffering Phar write operations, do not modify the Phar object on disk
void
stopBuffering()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Stop buffering write requests to the Phar archive, and save changes to disk
final static string
apiVersion()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the api version
final static bool
canCompress(int $compression = 0)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether phar extension supports compression using either zlib or bzip2
final static bool
canWrite()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether phar extension supports writing and creating phars
final static string
createDefaultStub(string|null $index = null, string|null $webIndex = null)
(Unknown)
Create a phar-file format specific stub
final static array
getSupportedCompression()
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Return array of supported compression algorithms
final static array
getSupportedSignatures()
(PHP >= 5.3.0, PECL phar >= 1.1.0)
Return array of supported signature types
final static void
interceptFileFuncs()
(PHP >= 5.3.0, PECL phar >= 2.0.0)
instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions
final static bool
isValidPharFilename(string $filename, bool $executable = true)
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns whether the given filename is a valid phar filename
final static bool
loadPhar(string $filename, string|null $alias = null)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Loads any phar archive with an alias
final static bool
mapPhar(string|null $alias = null, int $offset = 0)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Reads the currently executed file (a phar) and registers its manifest
final static string
running(bool $returnPhar = true)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Returns the full path on disk or full phar URL to the currently executing Phar archive
final static void
mount(string $pharPath, string $externalPath)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Mount an external path or file to a virtual location within the phar archive
final static void
mungServer(array $variables)
(Unknown)
Defines a list of up to 4 $_SERVER variables that should be modified for execution
final static bool
unlinkArchive(string $filename)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Completely remove a phar archive from disk and from memory
final static void
webPhar(string|null $alias = null, string|null $index = null, null|string $fileNotFoundScript = null, array $mimeTypes = [], callable|null $rewrite = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
mapPhar for web-based phars. front controller for web applications