Extracting files from .phar archive

epsilones picture epsilones · Oct 21, 2012 · Viewed 63.3k times · Source

There is something I entirely missed as for phar files. I am installing a project that requires phpunit, pdepend and other dependencies. I fetched them as .phar files. But, I am not able ot extract the files from them using command line tool (php command). I googled the problem, and I found nothing really answering the question. Could anyone help ?

Answer

Adrian Heine picture Adrian Heine · Jan 20, 2014

Extending on @pozs’s answer, you can actually use PharData->extractTo in a simple one-liner:

php -r '$phar = new Phar("phar-file.phar"); $phar->extractTo("./directory");'