I'll compare it to PsySH. Though this doesn't indicate any superiority in quality, I think it's important to note that Boris is arguably much more popular (measured in downloads from Packagist + stars on GitHub). From the start (back in 2011, before PsySH), Boris was meant to be tiny and light-weight in its core, weighing in at a few hundred lines of fairly straightforward code (brainstorming ideas for an extension API). Vanilla Boris is not as advanced as PsySH out-of-the-box, mostly a taste thing.
Sorry, my sentence was a bit ambiguous. Before Laravel 5 shipped, there had only been 15k Packagist installs total. After Laravel 5, it increased to almost half that every day.
Are you running Windows? If not, you've found a bug and should report it. If you are, you've discovered the reason Boris doesn't run at all on Windows :)
Seriously, though, if you're running on Windows you should report fatal errors that make PsySH crash as well. It works around a lot of them, but there will always be more, so let us know.
What advantage does this have over the built in REPL you can find with php -a (assuming readline instead of libedit)? They fixed fatal behavior a few versions ago, which was my last gripe with it.
No, you aren't missing anything. Maybe it's the Stockholm Syndrome of using PHP every day speaking, but I'm personally quite satisfied actually having to ask for output.
I have a PHP REPL on repl.it [1] but it's admittedly not that great because certain errors are impossible to recover from, for example a call to an undefined function just kills the process. I don't know how Boris does it but I should just use it.
I wrote a PHP repl back in the 5.2 days as I wanted one that could auto-complete, use readline, and survive fatal errors. My solution (really an experiment) was to write all the commands in a temp file and run that file out-of-band. This worked, but caused problems with having to pass global state around, and it didn't allow you to preserve local vars pointing to resources and such.
I dug into his code to see how he accomplished this:
* EvalWorker is responsible for evaluating PHP expressions in forked processes *
Which is a pretty cool setup. The whole thing is nicely architected and I'm looking forward to being able to use it!
exactly. side effects were definitely a problem, but it was an experiment and better than losing 20 prior commands!
I looked at his source and it's not clear to me how he's also not having the same problem; if the statement is run in a fork then how do you propagate the newly created resources back up to the master?
Still doesn't work on Windows. I don't care what people say ruby,node and python ,even Ipython repls work on Windows. So why can't we have a proper repl for PHP?
I don't know about the others, but this one works by using ext/pcntl, which isn't available natively on Windows. Try under cygwin? Crappy workaround...
Yeah. Unfortunately that's a limitation of PHP. It should be possible to use something like the Runkit extension to allow function and class redefinition, but it's not the best experience, and it requires compiling and installing a PHP extension that doesn't ship by default with any pre-built PHP I know of.
I find the primary advantage of a REPL being able to "explore" the language, or code. If I am trying to figure out how to slice a particular list of items and then split the items on a regex into key-value pairs for a map, sometimes I just prefer instant feedback and being able to mess around with live variables. That being said I often find that after about 5 minutes in (Python's) REPL I start wishing I had just written a script and run it in the interpreter instead, as going back to edit functions or build classes can be painful. Stuff like iPython offer solutions to this problem by integration with editors and more.
The speed you get feedback is the key imo. When I use a language that has a repl I usually find myself using it more than the text editor / ide. And in my experience there's a nice side effect too: since you cannot write too much in the repl, you end up writing smaller functions that leads to more modular, reusable code.
30 comments
[ 3.6 ms ] story [ 70.0 ms ] threadLaravel 5 is now using PsySH.
Seriously, though, if you're running on Windows you should report fatal errors that make PsySH crash as well. It works around a lot of them, but there will always be more, so let us know.
Am I missing something here?
[1]: http://repl.it/languages/PHP
I dug into his code to see how he accomplished this:
Which is a pretty cool setup. The whole thing is nicely architected and I'm looking forward to being able to use it!I looked at his source and it's not clear to me how he's also not having the same problem; if the statement is run in a fork then how do you propagate the newly created resources back up to the master?
It's impressive though and works well.