If you haven’t heard of it yet, there’s a very intersting tool available called phpsh, a python implementation to a PHP shell – but better.
Installing phpsh
SSH into your server, and download, build & install the binaries. This assumes you’ve downloaded the .tar.gz version.
# wget http://github.com/facebook/phpsh/tarball/master # tar xzf facebook-phpsh-1bc1c01.tar.gz # cd facebook-phpsh-1bc1c01/ # python setup.py build # python setup.py install # phpsh
As simple as that.
How to use phpsh?
Even more simple. Once the install is done, execute phpsh on the CLI, and get started writing PHP code.
srv ~ # phpsh Starting php type 'h' or 'help' to see instructions & features php> php> php> echo "Testing this new PHPSH"; Testing this new PHPSH php> php> php> $dbconn = mysql_connect('localhost', 'user', 'pass'); PHP Warning: mysql_connect(): Access denied for user 'user'@'localhost' (using password: YES) in /usr/lib/python2.4/site-packages/phpsh/phpsh.php(534) : eval()'d code on line 1 php> php> php> exit;
This can help to easily test or debug some PHP code. It has syntax highlighting, tab completion (!!), manual pages, … Still not convinced? Have a look at some real-life examples for a PHP interface shell. Seriously, awesome tool.