International PHP Conference Munich 2021

The PharData class

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 2.0.0)


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.


PharData extends RecursiveDirectoryIterator implements Countable , ArrayAccess {
/* 继承的常量 */
const int FilesystemIterator::SKIP_DOTS = 4096 ;
const int FilesystemIterator::UNIX_PATHS = 8192 ;
/* 方法 */
public addEmptyDir(string $dirname): void
public addFile(string $file, string $localname = ?): void
public addFromString(string $localname, string $contents): void
public buildFromDirectory(string $base_dir, string $regex = ?): array
public buildFromIterator(Iterator $iter, string $base_directory = ?): array
public compress(int $compression, string $extension = ?): PharData
public compressFiles(int $compression): void
public __construct(
    string $fname,
    int $flags = ?,
    string $alias = ?,
    int $format = Phar::TAR
public convertToData(int $format = ?, int $compression = ?, string $extension = ?): PharData
public convertToExecutable(int $format = ?, int $compression = ?, string $extension = ?): Phar
public copy(string $oldfile, string $newfile): bool
public decompress(string $extension = ?): PharData
public decompressFiles(): bool
public delMetadata(): bool
public delete(string $entry): bool
public extractTo(string $pathto, string|array|null $files = null, bool $overwrite = false): bool
public isWritable(): bool
public offsetSet(string $offset, string $value): void
public offsetUnset(string $offset): bool
public setAlias(string $alias): bool
public setDefaultStub(string $index = ?, string $webindex = ?): bool
public setMetadata(mixed $metadata): void
public setSignatureAlgorithm(int $sigtype): void
public setStub(string $stub, int $len = -1): bool


add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top