Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting files from .phar archive

Tags:

php

phar

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 ?

like image 490
epsilones Avatar asked Oct 21 '12 11:10

epsilones


People also ask

How do I extract a .PHAR file?

To unpack the PHAR archive, you need to click on the area below or drag the * . phar file into it with the mouse. As a result of unpacking, you will receive a ZIP archive. To package the PHAR archive, you need to click on the area below or drag the * .

How do I edit a .PHAR file?

You need download a PHAR file from languages here: https://osticket.com/download/#ostLang. Next, if you will edit this, you need extract it (PHAR is a PHP Archive: https://www.php.net/manual/en/intro.phar.php). If editing is done, pack it back to PHAR and copy into i18n folder.


1 Answers

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");' 
like image 108
Adrian Heine Avatar answered Sep 22 '22 19:09

Adrian Heine