2024 年日本 PHP 研討會

Phar 類別

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

簡介

Phar 類別提供了一個高階介面,用於存取和建立 phar 封存檔。

類別概要

class Phar extends RecursiveDirectoryIterator implements Countable, ArrayAccess {
/* 繼承的常數 */
/* 常數 */
常數 整數 BZ2;
常數 整數 GZ;
常數 整數 NONE;
常數 整數 PHAR;
常數 整數 TAR;
常數 整數 ZIP;
const int PHP;

(譯註:常數,整數類型)

const int PHPS;

(譯註:常數,整數類型)

const int MD5;

(譯註:常數,整數類型)

const int OPENSSL;

(譯註:常數,整數類型)

const int OPENSSL_SHA256;

(譯註:常數,整數類型)

const int OPENSSL_SHA512;

(譯註:常數,整數類型)

const int SHA1;

(譯註:常數,整數類型)

const int SHA256;

(譯註:常數,整數類型)

const int SHA512;

(譯註:常數,整數類型)

/* 方法 */
public __construct(string $filename, int $flags = FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS, ?string $alias = null)

(譯註:建構子,參數:檔名(字串),旗標(整數,預設為 FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS),別名(字串或null,預設為 null))

public addEmptyDir(string $directory): void

(譯註:新增空目錄,參數:目錄名稱(字串),回傳:無)

public addFile(string $filename, ?string $localName = null): void

(譯註:新增檔案,參數:檔名(字串),在phar檔案中的名稱(字串或null,預設為 null),回傳:無)

public addFromString(string $localName, string $contents): void

(譯註:從字串新增檔案,參數:在phar檔案中的名稱(字串),檔案內容(字串),回傳:無)

final public static apiVersion():字串
public buildFromDirectory(字串 $directory, 字串 $pattern = ""):陣列
public buildFromIterator(Traversable $iterator, ?字串 $baseDirectory = null):陣列
final public static canCompress(整數 $compression = 0):布林值
final public static canWrite():布林值
public compress(整數 $compression, ?字串 $extension = null):?Phar
public compressFiles(整數 $compression):
public convertToData(?整數 $format = null, ?整數 $compression = null, ?字串 $extension = null):?PharData
公開 convertToExecutable(?int $format = null, ?int $compression = null, ?string $extension = null): ?Phar
公開 copy(字串 $from, 字串 $to): true
公開 count(整數 $mode = COUNT_NORMAL): 整數
最終 公開 靜態 createDefaultStub(?字串 $index = null, ?字串 $webIndex = null): 字串
公開 decompress(?字串 $extension = null): ?Phar
公開 delMetadata(): true
公開 delete(字串 $localName): true
公開 extractTo(字串 $directory, 陣列|字串|null $files = null, 布林 $overwrite = false): 布林
公開 getAlias(): ?字串
公開 getMetadata(陣列 $unserializeOptions = []): 混合
公開 getPath(): 字串
公開 getStub(): 字串
final 公開 靜態 getSupportedCompression(): 陣列
final 公開 靜態 getSupportedSignatures(): 陣列
公開 getVersion(): 字串
final 公開 靜態 interceptFileFuncs():
公開 isFileFormat(整數 $format): 布林值
最終 公開 靜態 isValidPharFilename(字串 $filename, 布林值 $executable = true): 布林值
最終 公開 靜態 loadPhar(字串 $filename, ?字串 $alias = null): 布林值
最終 公開 靜態 mapPhar(?字串 $alias = null, 整數 $offset = 0): 布林值
最終 公開 靜態 mount(字串 $pharPath, 字串 $externalPath):
最終 公開 靜態 mungServer(陣列 $variables):
公開 offsetExists(字串 $localName): 布林值
公開 offsetGet(字串 $localName): SplFileInfo
公開 offsetSet(字串 $localName, 資源|字串 $value):
公開 offsetUnset(字串 $localName):
最終 公開 靜態 running(布林 $returnPhar = true): 字串
公開 setAlias(字串 $alias): true
公開 setDefaultStub(?字串 $index = null, ?字串 $webIndex = null): true
公開 setMetadata(混合 $metadata):
公開 setSignatureAlgorithm(整數 $algo, ?字串 $privateKey = null):
公開 setStub(資源|字串 $stub, 整數 $length = -1): 布林
公開 stopBuffering():
final public static unlinkArchive(字串 $filename): true
final public static webPhar(
    ?字串 $alias = null,
    ?字串 $index = null,
    ?字串 $fileNotFoundScript = null,
    陣列 $mimeTypes = [],
    ?可呼叫 $rewrite = null
):
public __destruct()
/* 繼承的方法 */
公開 SplFileInfo::getBasename(字串 $suffix = ""): 字串
公開 SplFileInfo::openFile(字串 $mode = "r", 布林值 $useIncludePath = false, ?資源 $context = null): SplFileObject
公開 SplFileInfo::setFileClass(字串 $class = SplFileObject::class):
公開 SplFileInfo::setInfoClass(字串 $class = SplFileInfo::class):
}

更新日誌

版本 說明
8.4.0 增加了對基於 Zip 封存的 Unix 時間戳記擴充的支援。

目錄

新增註記

使用者貢獻的註記

此頁面沒有使用者貢獻的註記。
To Top