unlink of “%s” failed, file does not exist¶
Description¶
PHP reports failure when trying to remove a file that does not exists in a phar archive. This error message does not appear when using the regular filesystem, or the delete
method on a phar
object.
This error message is part of the stream system.
Example¶
<?php
try {
$phar = new Phar('/tmp/myphar.phar');
$phar->addFromString('foo.txt', 'hello');
unset($phar);
$phar = new Phar('/tmp/myphar.phar');
unlink('phar:///tmp/myphar.phar/oops');
} catch (Exception $e) {
// handle errors
print $e->getMessage();
}
?>
Literal Examples¶
unlink of “oops” failed, file does not exist
Solutions¶
Check if the file is available before removing it, with
Phar::offsetExists
.