Categorized | Linux, News, PHP

PHP Gets a Respectable Shell At Last

Posted on 07 May 2006 by Demian Turner

This story was covered recently at, 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.

Bookmark and Share

3 Comments For This Post

  1. Johannes Says:

    PHP already (since PHP 5.1.0) has some shell, just build it –with-readline.

  2. Demian Turner Says:

    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.

  3. Jan Kneschke Says:

    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.

Leave a Reply



Demian Turner's currently-reading book recommendations, reviews, favorite quotes, book clubs, book trivia, book lists



PHPkitchen recommends you also check out the following sites :

Accounting for Small Businesses

FreeAgent sign-up