I started my programming career (many moons ago) coding in FoxPro. I love FoxPro. I can’t think of a better language to use for desktop database applications. I think the thing I love the most about FoxPro was the command window. From that window, I could travel to far off worlds…no wait, wrong window. In the FoxPro command window I can execute commands, instantiate objects, explore properties; in short, just about everything I can do in FoxPro itself. It’s a great prototyping tool for all the non-visual stuff. I’ve missed the immediacy of the command window in every other language I’ve worked in. I no longer miss it in PHP!

Since version 5.1 of PHP, if you compiled the CLI version with—with-readline, you could get an interactive shell. While not perfect it was a huge step in the right direction. As good as it is, there are still problems. Like all good Open Source software, there are no problems that can’t be overcome by a determined programmer. In this particular case, I found three.

First up. The most recent entry, Jan Kneschke has released a class and a script called php_shell. His is truly a “scratch your own itch” solution. He wrote it for himself and his QA team but was nice enough to share it with the rest of us. I downloaded and installed the class and script. With very little fuss, I had a cool little interactive shell. You just need to place the php-shell.php front-end script on the path and drop PHP_Shell.php file containing the actual class in the same directory (php-shell.php by default “requires” it from the current directory, which you can change to use your include path by fixing the “require” statement near the top of the file).

Next, phpa contributed by David Phillips. It’s a single file solution. Nothing fancy here. But unlike php_shell, you do have to have readline compiled in. Since I don’t, I wasn’t able to test it in time for this article. It looks solid enough, so give it a go.

Finally, phpinteractive. This one is cool in a very dangerous way. (Cool as in “Jackass: The Movie” cool. You know, you would never do something that crazy but you’ll watch others do it.) In a controlled environment, this little web based tool is great. You type in your code, click update and it executes it on the server and gives you the output. The only way it could be any cooler is if it used some kind of AJAX. (But I digress) Don’t ever put this script where others can get to it or you may find more than your dirty laundry hanging out on the web for all to see. They kinda gloss over that in the instructions but seriously, on an intranet server this would rock for quick testing of concepts etc. On a production server, it’s going to be trouble. Be careful with it. Use at your own risk.

That’s all for today…

=C=

UPDATE: Johannes Schluter who contributed the interactive console to PHP wrote me to correct me, it’s only been available since 5.1, not 5.0. Thanks Johannes!