I think the tool you're looking for is called "pear." Avoid re-inventing the wheel here. If there is a shortcoming in PEAR, then you need to address that shortcoming. Take a peek at 1.4.0 now that I've dived into unit testing. Specifically these things will be very useful:
PEAR_PackageFile_v*->getFileContents()
used to retrieve the contents of a file from the .tgz or .tar based on its name in the package.xml (should remove the profanity from non-working compression :)
the ability to define custom roles. Simply define a bootstrap role, and you can define the start script with
<file role="bootstrap" name="whatever.php"/>
This will also be good because you'll be able to take existing pear packages and create .phars from them with minimal changes.
This does sound alot cleaner, Although I do wonder how includes work from within the archive?
[phar::somefile.tgz]
...abc.php.. -> "include '/def/xyz.php';
...def/xyz.php
unless you are adding phar::somfile.tgz to the include path?? - in which case does include path accept transport types..
Regards
Alan
Greg