This story was covered recently at planet-php.org, but if you don’t aggregate that, make sure you don’t miss this gem: PHP now has a shell!
I remember this being promised and blogged about around a year ago, but it doesn’t seem to have materialized until now. If you’ve used the Python interactive shell, you immediately notice how PHP’s equivalent is the poor relation.
Thanks to Jan Kneschke this is no longer the case. A very nice program he’s written, PHP 5 only, you can download the files here and here.
For the last few years I’ve been trying to build the considerable patience required to use the default shell available in PHP. If you have any parse errors, it dies, and of course you have to keep typing "<?php" everytime you re-fire it up.
Jan’s version is a considerable improvement, and although it doesn’t yet handle up-arrow for previous LOC or back-arrow in case you type your parentheses first and want to fill in the variables after, it’s a welcome relief to work with. I’m sure it will delay the capitulation when you give up and create a stupid file and request it in a browser just to test some little PHP detail.
May 7th, 2006 at 11:10 pm
PHP already (since PHP 5.1.0) has some shell, just build it –with-readline. http://blog.thinkphp.de/archives/44-More-PHP-power-on-the-command-line.html
May 8th, 2006 at 12:49 am
Yes, that’s the article I was talking about, you can see my original trackback at the bottom. No luck compiling PHP –with-readline though, in the configure it is successfully detected and I get no errors, but readline doesn’t show up in the phpinfo() afterwards, and invoking php -a does not give results as per the thinkphp article.
May 8th, 2006 at 4:30 am
On windows you have arror-key handling by default, on unix you need readline support.
I just updated the php-shell class to use readline support of available. This also brings tab-completion for most scenarios. Check out the examples.