Dependent Origination

installing phpsh

Posted on: August 10, 2012

reason why we need phpsh?

1. it is awesome🙂

2. when we were using ubuntu 10, you can do php -a and it is a decent interactive shell for vanilla php. and i run into problems making phpsh recognizing our own database so i just get by php -a for a while. but now that we upgraded to xfce, it turns out there is licensing issues with read-line, so xfce (and some other distributions) comes with php without read-line support, which means php -a is now practically useless.

3. phpsh can work with your own codebase, which makes testing, prototyping orders of magnitude easier.

so here we go, installing phpsh.

the vanilla one (phpsh) works out quite easy. the trouble is always at (phpsh your_code_base_include_file_list). when you try to access your own php classes, functions etc, it is always class not found. why?

in fact, i don’t understand why. the way phpsh works, it is a python script that invokes a php script, and establishes pipes to the php processes. when you invoke the php script, it calls ‘php file options etc’ directly, which in turn should be reading the /etc/php5/cli/php.ini file, where you can change include_path so it would find your classes.

but it doesn’t work — for some reason, the installation on the network drive doesn’t seem to read in the php.ini on my drive at all. a really local installation in fact can read it.

anyway, how to make it work? lots of options.

1. you can change inside the phpsh.py script, the comm_base parameter, when invoking php, instead of ‘php’, put in ‘php -c /etc/php5/cli/php.ini’ –> this works, i tested. however, not sure if it works with the xdebug enabled version of phpsh.

2. alternatively, you can change the phpsh.php script, do ini_set(‘include_path’, ‘path_to_your_codebase’) and it works, i tested.

the benefits of these approaches are you can put in multiple include paths, in case the php code you want to play with scatters around. but these requires changes every time you update phpsh (if you do that at all).

3. the easiest approach doesn’t require you to do anything — just invoke phpsh include_file_list from the directory you would have put in include_path. –> for most cases, this should just work.

that is a fun few hours to figure out what is going on with phpsh🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

August 2012
M T W T F S S
« Jul   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Twitter

  • is looking at other people's intentions, not their capabilities, and feeling much happier every day :) 11 months ago
  • is planning on how to spend the next two weeks until the new year, at home. 11 months ago
  • is going to have human company for Thanksgiving; a rare event for the past like twenty years. 1 year ago
  • living by myself again; a strange feeling in a bustling city with thirteen million people 1 year ago
  • just came back home after sixteen days on the road; when i set out, the plan was a mere three-day trip 1 year ago

Flickr Photos

IMG_3150

IMG_3175

IMG_3169

IMG_3139

IMG_3120

IMG_3111

IMG_3086

IMG_3079

IMG_3054

IMG_3048

More Photos
%d bloggers like this: