Interactive Shells. They aren’t just for seafood anymore.
p. 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!
p. Since version 5.1 of PHP, if you compiled the CLI version with –with-readline, you could get an “interactive shell”:http://blog.thinkphp.de/archives/44-More-PHP-power-on-the-command-line.html. 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.
p. First up. The most recent entry, “Jan Kneschke”:http://jan.kneschke.de/me/ has released a class and a script called “php_shell”:http://jan.kneschke.de/projects/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).
p. Next, “phpa”:http://david.acz.org/phpa/ contributed by “David Phillips”:http://david.acz.org/david.jpg. 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.
p. Finally, “phpinteractive”:http://www.hping.org/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”:http://thedailywtf.com/forums/68199/ShowPost.aspx. (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.
p. That’s all for today…
p. “=C=”:http://blog.calevans.com
p. UPDATE: “Johannes Schluter”:http://www.schlueters.de:8000/blog.php?id=44 who contributed the “interactive console”:http://www.schlueters.de:8000/blog.php?id=44 to PHP wrote me to correct me, it’s only been available since 5.1, not 5.0. Thanks Johannes!
Categories: News
Tags: All Skill Levels, Interactive Shell, PHP5, Shell


One comment to “Interactive Shells. They aren’t just for seafood anymore.”
May 11th, 2006 at 11:28 am
I too started my programming career (many moons ago) coding in FoxPro. I too love FoxPro and can not think of a better language to use for desktop database applications. I’ve played with PHP and MySql for a few years now. I support open source and want to contribute but I haven’t quite caught on yet. I’ve been following the Zend Framework waiting for it all to click. I’m very excitted to now have this "command window" like tool and I think this will get me over the hump. Whenever I was uncertain about how something was to work in FoxPro I was able to quickly get an understanding via the command window, and that is invaluable. Wonderful find!