PharData
class PharData extends Phar (View source)
The PharData class provides a high-level interface to accessing and creating non-executable tar and zip archives. Because these archives do not contain a stub and cannot be executed by the phar extension, it is possible to create and manipulate regular zip and tar files using the PharData class even if phar.readonly php.ini setting is 1.
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 >= 2.0.0)
Construct a non-executable tar or zip archive object
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
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
(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
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns phar archive meta-data
(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
No description
No description
(PHP >= 5.3.0, PECL phar >= 2.0.0)
set the contents of a file within the tar/zip to those of an external file or string
(PHP >= 5.3.0, PECL phar >= 2.0.0)
remove a file from a tar/zip archive
(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 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
Details
__construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS, string $alias = null, int $format = 0)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a non-executable tar or zip 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
in
Phar at line 492
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
in
Phar at line 983
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
in
Phar at line 65
__destruct()
No description
in
Phar at line 76
void
addEmptyDir(string $directory)
(Unknown)
Add an empty directory to the phar archive
in
Phar at line 95
void
addFile(string $filename, string $localName = null)
(Unknown)
Add a file from the filesystem to the phar archive
in
Phar at line 113
void
addFromString(string $localName, string $contents)
(Unknown)
Add a file from the filesystem to the phar archive
in
Phar at line 137
array
buildFromDirectory(string $directory, $pattern = '')
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a phar archive from the files within a directory.
in
Phar at line 159
array
buildFromIterator(Traversable $iterator, string $baseDirectory = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Construct a phar archive from an iterator.
in
Phar at line 176
void
compressFiles(int $compression)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Compresses all files in the current Phar archive
in
Phar at line 185
bool
decompressFiles()
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses all files in the current Phar archive
in
Phar at line 207
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
in
Phar at line 226
Phar|null
decompress(string $extension = null)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Decompresses the entire Phar archive
in
Phar at line 260
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
in
Phar at line 296
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
in
Phar at line 312
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
in
Phar at line 327
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
in
Phar at line 340
bool
delete(string $localName)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
Delete a file within a phar archive
in
Phar at line 351
bool
delMetadata()
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Deletes the global metadata of the phar
in
Phar at line 371
bool
extractTo(string $directory, string|array|null $files = null, bool $overwrite = false)
(Unknown)
Extract the contents of a phar archive to a directory
in
Phar at line 382
string|null
getAlias()
No description
in
Phar at line 394
mixed
getMetadata(array $unserializeOptions = [])
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns phar archive meta-data
in
Phar at line 403
bool
getModified()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return whether phar was modified
in
Phar at line 419
array|false
getSignature()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return MD5/SHA1/SHA256/SHA512/OpenSSL signature of a Phar archive
in
Phar at line 430
string
getStub()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return the PHP loader or bootstrap stub of a Phar archive
in
Phar at line 443
string
getVersion()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Return version info of Phar archive
in
Phar at line 452
bool
hasMetadata()
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Returns whether phar has global meta-data
in
Phar at line 461
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
in
Phar at line 470
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)
in
Phar at line 483
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)
No description
mixed
offsetGet(string $localName)
No description
void
offsetSet(string $localName, TValue $value)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
set the contents of a file within the tar/zip to those of an external file or string
void
offsetUnset(string $localName)
(PHP >= 5.3.0, PECL phar >= 2.0.0)
remove a file from a tar/zip archive
in
Phar at line 557
bool
setAlias(string $alias)
(PHP >= 5.3.0, PECL phar >= 1.2.1)
Set the alias for the Phar archive
in
Phar at line 573
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
in
Phar at line 589
void
setMetadata(mixed $metadata)
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Sets phar archive meta-data
in
Phar at line 615
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.
in
Phar at line 633
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
in
Phar at line 646
void
startBuffering()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Start buffering Phar write operations, do not modify the Phar object on disk
in
Phar at line 655
void
stopBuffering()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Stop buffering write requests to the Phar archive, and save changes to disk
in
Phar at line 664
final static string
apiVersion()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns the api version
in
Phar at line 677
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
in
Phar at line 685
final static bool
canWrite()
(PHP >= 5.3.0, PECL phar >= 1.0.0)
Returns whether phar extension supports writing and creating phars
in
Phar at line 697
final static string
createDefaultStub(string|null $index = null, string|null $webIndex = null)
(Unknown)
Create a phar-file format specific stub
in
Phar at line 708
final static array
getSupportedCompression()
(PHP >= 5.3.0, PECL phar >= 1.2.0)
Return array of supported compression algorithms
in
Phar at line 717
final static array
getSupportedSignatures()
(PHP >= 5.3.0, PECL phar >= 1.1.0)
Return array of supported signature types
in
Phar at line 725
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
in
Phar at line 740
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
in
Phar at line 757
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
in
Phar at line 772
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
in
Phar at line 784
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
in
Phar at line 802
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
in
Phar at line 817
final static void
mungServer(array $variables)
(Unknown)
Defines a list of up to 4 $_SERVER variables that should be modified for execution
in
Phar at line 829
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
in
Phar at line 910
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