Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does PHP's Phar::mapPhar() method do?

Tags:

php

manifest

phar

I'm considering creating a phar stub to use in a PHP CLI application.

The documentation for the Phar::mapPhar method says it "Reads the currently executed file (a phar) and registers its manifest".

Could you explain what it means to 'register its manifest' and also indicate what would happen if it were called with no arguments. Why would I want to register a manifest? What benefits do i get from adding this call to my phar stub.

like image 304
JW. Avatar asked Nov 13 '22 21:11

JW.


1 Answers

Phar::mapPhar() reads the phar's file index ("manifest") and registers it internally, so that file operations like

include 'phar://my.phar/foo/bar/baz.php';

work. Without mapping the phar, PHP would not know that phar://my.phar/foo/bar/baz.php exists (nor where to find it).

like image 125
cweiske Avatar answered Dec 25 '22 18:12

cweiske