As recently commented, PHP has been in great need of a decent shell environment for some time now and, as users of Python and, even better, Ruby’s irb will maintain, access to all the language’s constructs and libs at the commandline is a great timesaver and should be a standard feature for all scripting languages.
Luckily for PHPers Jan Kneschke has come to the rescue and implemented PHP Shell in userland PHP, which provides many of the features that come by default in the aforementioned languages’ interactive shells. If your PHP is compiled –with-readline support even better, standard up-arrow command history is available, as is the ability to backspace into the code you have written but not yet executed.
What is newsworthy about PHP Shell is that it has recently was made available as a PEAR lib, so it’s just a matter of
$ pear install PHP_Shell-alpha
and then execute the php-shell.sh script which is discoverable in your PATH if you’re using Linux (or there is a cmd equivalent for Windows users still on the dark side).
Although the docs section of PHP_Shell is still empty at the PEAR site, a README is available with the package with all the basic info you will need, or just type ‘?’ at the command line once interactive script is running.
I personally think this is one of the more exciting PEAR releases to come about in a long time. Not to diminish the importance of the steady and voluminous release of packages enjoyed by the PEAR project (and more so by PHP users) over the last months, but PHP Shell is something I will use on a daily basis as part of earning my living as a programmer, along with phpDocumentor, PEAR::Log and Mail and many of the bread and butter packages required for any decent web app.
At a time where the trend is to move away from PEAR, or to rewrite many of the PEAR libs from scratch instead of improving existing work (ezComponents, Zend Framework), I tip my hat to the hard working PEAR community and wish the project the continued success it deserves, despite current fashion trends.








June 15th, 2006 at 10:01 am
Note that Php Shell is still in alpha mode – so the default Pear config will not install it. You can either download it manually, or use the -f switch :
pear install -f PHP_Shell
June 15th, 2006 at 10:18 am
Thanks for pointing that out, I always run in devel so never notice
June 15th, 2006 at 11:32 am
You could also use pear install PHP_Shell-alpha
June 15th, 2006 at 1:15 pm
> to rewrite many of the PEAR libs from
> scratch instead of improving existing
> work (ezComponents, Zend Framework)
Should Seagull be part of that list?
June 15th, 2006 at 1:36 pm
Amazing, I guess you really can learn something from comments
Chris, FYI the Seagull framework is built *on top* of PEAR libs, was one of the first adopters of things like DB_DataObjects and Flexy templates, and has provided stacks of bug reports and some patches to the PEAR community in the 5 years of it has been working with PEAR. A default Seagull install comes with around 22 PEAR libs.
I can’t think of a framework project out there in PHP land that is more dedicated to the PEAR effort.
We were also one of the first to make full use of PEAR channels, and provide tools for gui frontend to download channel packages.
Now as you’re apparently interested in the subject, and a ZPF contributor, what’s your take on my comment now that you’re a bit more informed?
June 15th, 2006 at 2:53 pm
I don’t have a strong opinion about these things, so I doubt my perspective will interest anyone. I watched the panel at php|tek on frameworks, so I did get a better idea regarding some of the design decisions. One thing worth noting is that ZF is designed to coexist peacefully with other component libraries such as PEAR. I don’t think there’s too much direct competition, because PEAR will never want to be a framework, and ZF will never have many components.
Even if there is some direct competition, I don’t see reinventing the wheel as disrespectful. We’re all different, and sometimes the PEAR solution doesn’t suit us for some reason. (I can say the same thing about the ZF solution in some cases, of course.) That’s why I think CPAN will always have us beat. As Andy Lester so eloquently puts it, “CPAN thrives because of the unfettered uploading of shit, not in spite of it.”
Anyway, thanks for the quick explanation of Seagull.
P.S. Your comment system needs some nl2br() action.
June 16th, 2006 at 4:08 pm
Could the command “pear install PHP_Shell” install it successfully? it came out this in windows xp:
Failed to download pear/PHP_Shell within preferred state “stable”, latest releas
e is version 0.3.0, stability “alpha”, use “channel://pear.php.net/PHP_Shell-0.3
.0″ to install
Cannot initialize ‘PHP_Shell’, invalid or missing package file
Package “PHP_Shell” is not valid
install failed
I installed it by the command as the following at last:
pear install channel://pear.php.net/PHP_Shell-0.3.0
June 17th, 2006 at 12:00 pm
I’ve been using this weblog for > 1 year and didn’t realise you had to enable the nl2br plugin to sort the comments – that’s what I call plugin-based architecture
December 2nd, 2006 at 10:57 pm
Das Entwickeln mit PHP macht Spass. Es ist ziemlich einfach möglich auch komplexere Aufgabenstellungen umzusetzen. Jedoch finde ich Fehler meist erst durch Testläufe meiner Software.
Als ich mit Python entwickelt habe fand ich die interaktive Shell ung