php8.5
Home/ Manual/ phar / Phar/ Phar::unlinkArchive

Phar::unlinkArchive

PHP function Edit on GitHub ✎

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

Completely remove a phar archive from disk and from memory

Description

Phar::unlinkArchive(string $filename): true

Removes a phar archive from disk and memory.

Parameters

filename

The path on disk to the phar archive.

Return Values

Always

Errors/Exceptions

PharException is thrown if there are any open file pointers to the phar archive, or any existing Phar, PharData, or PharFileInfo objects referring to the phar archive.

Examples

A Phar::unlinkArchive() example

php
<?php
// simple usage
Phar::unlinkArchive('/path/to/my.phar');

// more common example:
$p = new Phar('my.phar');
$fp = fopen('phar://my.phar/file.txt', 'r');
// this creates 'my.phar.gz'
$gp = $p->compress(Phar::GZ);
// remove all references to the archive
unset($p);
fclose($fp);
// now remove all traces of the archive
Phar::unlinkArchive('my.phar');
?>

See Also

Source: reference/phar/Phar/unlinkArchive.xml · from the official PHP manual (php/doc-en)