Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Christian Weiske:
Running a phar without .phar extension
Dec 18, 2015 @ 17:18:13

Christian Weiske has a quick tip posted to his site for those using phar archives in PHP and how to remove the .phar extension and still have them execute correctly.

I'm shipping a new side project as .phar file, php-sqllint.phar. The phar stub has a shebang line so that I can call it without explicitly running PHP. [...] When making the file executable with chmod +x, you can simply execute it.

He wanted to remove the extension but was greeted with an error message when he tried to execute the result. He stumbled on the solution in this PHPUnit bug and corrected the problem with a call to the Phar::mapPhar method inside the phar archive file.

tagged: phar archive extension remove mapphar tutorial

Link: http://cweiske.de/tagebuch/phar-renaming-no-ext.htm


Trending Topics: