Skip to content
This repository

phpsh is a read-eval-print-loop for php that features readline history, tab completion, and quick access to documentation. It was developed at Facebook and ironically, is written mostly in python. It is open source and released under a modified BSD license.

tree: b9ab98cdad

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 src
Octocat-spinner-32 test
Octocat-spinner-32 LICENSE Initial commit for new public phpsh repo. October 13, 2008
Octocat-spinner-32 README
Octocat-spinner-32 rc.example.php rc comment punctuation September 27, 2009
Octocat-spinner-32 phpsh 1.3; no duplication with version; dbgp becomes actual script March 23, 2010
Mailing list at:

Python dependencies:
- pysqlite
- readline

To install globally:
(Note that this install currently clobbers any previous /etc/phpsh/rc.php)
~ python build
~ sudo python install
~ phpsh

To install locally:
(Note that this install currently clobbers any previous ~/.phpsh/rc.php)
~ python install --prefix=~
~ export PYTHONPATH=~/lib/python2.6/site-packages
(Adjust this if your python minor version differs from 2.6)
~ ~/bin/phpsh
(You will probably want to put the PYTHONPATH line in your .bashrc or such,
and just add ~/bin to your PATH as well.)

There are more details on installing from a at

To set up after install:
- If you just want to use vanilla php, just do ~ phpsh  and have fun.
- To connect to an actual codebase, e.g.:
  ~ cd ~/www
  ~ ctags -R            # for phpsh ctags integration, recommended
  ~ phpsh lib/init.php  # or some file(s) that load codebase libraries
- To get autoloading, modify /etc/phpsh/rc.php.  After that it's just:
  ~ cd ~/www
  ~ phpsh
  And for times when you just want vanilla php:
  ~ phpsh -c none
- For individual configuration, also see rc.example.php in the php

Note to ppl hacking on phpsh:
- For faster iteration, after installing once, you can run phpsh from src/
directly without reinstalling.  E.g.:
  ~ cd ~/www
  ~ ~/projects/phpsh/src/phpsh

Todo for after phpsh 1.2
- (A) Simple phpsh breakpoints that you can insert into your php code.
- (B) magic fatal undoing?
- Convert from /tmp file to named pipe for 'ready' message passing
- Maybe phpsh_check_syntax shouldn't actually be installed as a script, and
  just be a pkg_resource?  Didn't want to worry about zip file overhead, and
  installing didn't seem like a big deal.
- Similarly, php_manual.db should probably go in share/ not etc/ but similarly
  was worried about b.s. with setuptools..
- Paging for long php> d ..  results?  Or is terminal scroll fine..
- Thread loading ctags and starting php?  Would speed start but not restart.
- Command-line apc for faster php startup for large codebases.
- Note on php start error to start from codebase place?
- Make tab to show function signature work with multiline func sigs.

About (A: breakpoints):
jlindamood has suggested adding
a very basic debugging facility in which phpsh.php would define some
function called like phpsh_breakpoint() which you would be able to put
in your code that would cause the php> to re-happen at that breakpoint
so that you can investigate whatever state until you issue like a
phpsh_resume() (or whatever it would be called).

My suspicion is that that can be done pretty easily be having a new
message type from phpsh.php to  (Currently there is only the
'ready' message when phpsh.php is ready to receive a new line of codes

About (B: fatal-undoing):
brent suggested adding
some kind of katamari-esque memory snapshotting, so that on fatals like
calling a nonexistent function (which are not catchable in php-land,
sadly) can be magically recovered from.  I think dweatherford or larry
would be good to ask about this kind of black magic.
Something went wrong with that request. Please try again.