PHP Phar command line errors on OS X: Running 'php some.phar' generates '?????'

Sep 15 2010

When I tried to run pyrus.phar on Mac OSX recently, I had a strange experience. Executing php pyrus.phar generated the output ??? and then exited. With a little more testing, I discovered that all of my Phar packages, when from from the command line, generate "garbage" output (a series of question marks, usually) and then exit.

Quite a bit of digging later, I discovered an old bug report (recently re-opened) that documents the problem and suggests a solution. In a nutshell, the problem is that the Zend engine Unicode checker is enabled by default in at least some versions of PHP 5.3. My Apple-built PHP package (included in the Snow Leopard releases) has this problem, and I suspect that other builds do too.

While there is no solution yet, the workaround is as simple as setting the following ini directive:

detect_unicode = Off

While I'm not a huge fan of this workaround, it definitely works. I simply added it to my /etc/php.ini file, and now I can run pyrus and other Phar files.



comments powered by Disqus