phpsh, An Interactive Shell For PHP (Debian Etch)
Version 1.0
Author: Falko Timme
phpsh is an interactive shell for php that features readline history, tab completion, quick access to documentation. It was developed at Facebook and ironically, is written mostly in python. This article explains how you can install/use it on a Debian Etch system.
This document comes without warranty of any kind! I do not issue any guarantee that this will work for you!
1 Installing phpsh
phpsh depends on PHP (4 or 5, 5 is recommended) and Python 2.4+, therefore we install PHP5 and Python as follows:
apt-get install php5-cli python
Afterwards we download and uncompress phpsh as follows:
wget http://www.phpsh.org/phpsh-latest.tgz
tar xvfz phpsh-latest.tgz
This creates the directory phpsh with the phpsh executable. Before we can run phpsh, we must make it executable:
cd phpsh
chmod 755 phpsh
2 Using phpsh
Now we can start the PHP shell simply by running
./phpsh
http://www.phpsh.org/readme.php shows how you can use the PHP shell. You can use tab to autocomplete function names, global variable names, constants, classes, and interfaces, and you can use the arrow keys to browse the command history. The equal sign at the beginning of a line will return the value of an expression.
Type
q
to leave the PHP shell.
Here's a sample output:
server1:~/phpsh# ./phpsh
I can't find a tags file for you. To enable tab completion in phpsh,
go to the root directory of your php code and run 'ctags -R',
(or whatever the analagous command is with your version of ctags,)
then run phpsh from that directory or a subdirectory of that directory.
Commandline: php -q /root/phpsh/phpsh.php
phpsh (c)2006 by Charlie Cheever and Dan Corson and Facebook, Inc.
type 'h' or 'help' to see instructions & features
New Feature: You can use the -c option to turn off coloring
php> = 2 + 3
5
php> $test = "This is a test.";
php> echo $test;
This is a test.
php> = array(array(1,2,3), array("a" => "b", "c" => "d", "e" => "f"), 'g', 'h')
Array
(
[0] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
[1] => Array
(
[a] => b
[c] => d
[e] => f
)
[2] => g
[3] => h
)
php> $a = "abcdefg";
php> echo substr($a,0,3);
abc
php> q
server1:~/phpsh#
3 Links
- phpsh: http://www.phpsh.org/
- Debian: http://www.debian.org/