I was just wondering if it is legal to add static content to phar archives (images, javascript or html files). And if so, how do I get them out to serve to a client?
The only example I've seen so far was:
<?php
header('Content-type: image/jpeg');
echo file_get_contents('phar:///fullpath/to/coollibrary.phar/images/wow.jpg');
?>
but I guess this is not a way to go.
UPATE: Just in case someone will be trying to do the same. This piece of code set as a stub of a phar archive worked for me:
<?php
Phar::interceptFileFuncs();
Phar::mungServer(array('REQUEST_URI'));
Phar::webPhar();
__HALT_COMPILER();
?>
All static content inside the phar archive still passes through the php interpreter, but at least there is no need do stuff like setting header mime type and serving the static file content with readfile() manually. Those functions in the phar stub make it look transparent.