Using phpsh with emacs as a true repl?

75 views
Skip to first unread message

defn

unread,
Mar 1, 2010, 8:19:42 AM3/1/10
to phpsh
Hello, I am interested in using phpsh inside emacs in the way I've
used SLIME in the past. Has anyone, to your knowledge, built anything
similar for phpsh that would allow one to evaluate code in a text
buffer and essentially load that code into the phpsh repl?

dan corson

unread,
Mar 1, 2010, 7:20:27 PM3/1/10
to ph...@googlegroups.com
Hi, I don't use emacs much personally, but I asked a coworker about
his setup where he runs phpsh inside emacs. The information he gave
is below. I wish I had more information. Definitely let us know if
you run into any issues where something in the (mis-)architecting of
phpsh causes issues with emacs. --dan


I just run phpsh in emacs comint-mode (nee shell mode) like this:

ph() {
x="`pwd`"
cd $HOME/ws/tfb
phpsh --no-color
cd $x
}

This has worked pretty well.

But what devinw is asking for sounds like a lower level interaction. Somenthing
where I can just type

$foo = Array(1,2,,3,5);

And then run 'eval-sexp on the text.

I haven't done that.

defn

unread,
Mar 1, 2010, 9:11:03 PM3/1/10
to phpsh
Hi Dan,

Thanks for the reply. comint-mode is a good idea. I'm looking over
the inf-ruby source right now and am planning on trying to implement
something similar for phpsh. I also think it might be possible to
sanity check PHP code before it is evaluated by the phpsh process
(perhaps in another dummy phpsh process) to achieve what is mentioned
at the end of the phpsh github repo README:

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.


Does that sound like something worth tackling to you? I am busy with
some work over the next few days but I am going to try and get a
github repo up with my emacs mode and will let the group know when
I've done so.

Thanks,

dan corson

unread,
Mar 2, 2010, 6:30:57 AM3/2/10
to ph...@googlegroups.com
Cool, any ideas or patches for editor integration are always welcome.

We actually have now implemented one pre-eval sanity-check; we started
checking for undefined functions. It's a simple check (doesn't handle
OO yet: $a->tihs_is_a_typo() will still fatal; and it doesn't handle
dynamic things like call_user_func() -- doing so in full generality is
uncomputable). We're definitely interested in expanding these checks
to reduce annoying fatals. Ideally PHP would change so that more
errors in dynamic execution are catchable. --dan

Reply all
Reply to author
Forward
0 new messages