Installing PHPsh on Linux, Python Error

Installing phpsh on Turnkey Linux and cannot built setup.py

[update] I know this question is old. But FWIW v14.0 TurnKey Linux has phpsh pre-installed on LAMP/LAPP based appliances.

FWIW I can reproduce this issue on TurnKey LAMP 13.0

However, Python should be there (in /usr/lib/python2.7). At least it is on my test server. FWIW have a look at the output of:

whereis python

/usr/lib/python2.7 should be one of the many results returned (again at least it was on mine).

If you reread the error message, the file that is missing (which it's complaining about it) is 'make'!

Try this:

apt-get update && apt-get install build-essential

Then you should find that

python setup.py build

now completes successfully! :)

Run phpsh with specific php script

It's not supported by default, but you can quickly add.

It by applying this patch to your phpsh.py in the src folder:

--- phpsh.py     2011-05-13 18:16:32.000000000 -0400
+++ phpsh.py 2013-12-05 14:50:11.906673382 -0500
@@ -253,6 +253,7 @@
def __init__(self):
self.config = ConfigParser.RawConfigParser({
"UndefinedFunctionCheck": "yes",
+ "PathToBinary" : None,
"Xdebug" : None,
"DebugClient" : "emacs",
"ClientTimeout" : 60,
@@ -388,6 +389,8 @@
except Exception, msg:
self.print_error("Failed to load config file, using default "\
"settings: " + str(msg))
+ if self.config.get_option("General", "PathToBinary"):
+ os.environ['PATH'] = self.config.get_option("General", "PathToBinary") + ':' + os.environ['PATH']
if self.with_xdebug:
xdebug = self.config.get_option("Debugging", "Xdebug")
if xdebug and xdebug != "yes":

If you want to modify an already installed version, find your pythons site-pages folder and apply the patch on both init.py and phpsh.py in that folder.

This will add a new configuration variable so in phpsh/config (in /etc/phpsh/config if installed as root, or ~/.phpsh/config if user). In there you can specify the path to your php binary

PathToBinary: /srv/bin

This is just the path where the binary should be found, not the path binary itself, i.e. /srv/bin/php will not work.

How to use the PHP interactive shell

Try installing phpsh. It is probably the easiest solution.

Steps (assuming dependencies are installed):

  1. git clone https://github.com/facebook/phpsh
  2. cd phpsh
  3. sudo python setup.py install
  4. phpsh

How to do multiline input in phpsh?

Let's take an example, if multiline statement:

  1. Type: if (condition) {
  2. Just hit Enter
  3. ... and write what you want.
  4. } Close the multiline statement. And hit Enter to execute it.

You can further cancel writing by hitting ctrl + c.



Related Topics



Leave a reply



Submit