Hacker News new | past | comments | ask | show | jobs | submit login
Boris: A tiny but robust REPL for PHP (github.com/d11wtq)
121 points by nodesocket on May 8, 2013 | hide | past | favorite | 46 comments



That looks good, although one may wonder at the long term support prospects (the author says "I'm in the process of transitioning away from PHP to Ruby.").

For your delectation, other PHP repls include :

- The basic built-in repl "php -a"

- Facebooks phpsh : http://phpsh.org/

- PHP Shell : http://jan.kneschke.de/projects/php-shell

- php-repl : https://github.com/tailrecursion/wigwam

If you want something more customised to your needs, investigate the plethora of readln and posix functions in PHP and dive right in!


That is a fair concern to have, though I will be working on and maintaining Boris for the foreseeable future (already have a bunch of features planned, to make it more extensible).

As with Swift Mailer, which I maintained for many years, if the time comes for somebody else to take the project over, Boris will live on under a new maintainer. That's very unlikely in the next couple of years though. Plenty of activity via pull requests now.


I was having several issues with phpsh (and it looks like it hasn't been updated for 2 years now - https://github.com/facebook/phpsh). Just tried Boris and it seems to be working good!


To those who, like me, thought PHP already has this:

> PHP's interactive mode does not print the result of evaluating expressions and more importantly, it exits if you type something that produces a fatal error, such as invoking a function/method that does not exist, or an uncaught exception. Boris is designed to be robust, like other REPLs, so you can experiment with things that you know may error, without losing everything.


It looks like a great replacement for Facebook's unmaintained phpsh [1] (written ironically in Python).

In a similar vein to @gingerlime, anyone know a PHP mode for IPython [2]? It'd be great to prototype my code in a notebook.

1. http://phpsh.org/ 2. http://ipython.org/


I was wondering the exact same thing. Sounds cool.

Anybody knows of a debugger equivalent to ipdb (python) / pry (ruby) for php to allow live debugging stuff on the server?


You can live-debug with xdebug. Have been using it with vim and it worked.


Seconded. xdebug and the vim plugin "vdebug" ( https://github.com/joonty/vdebug ) work like a charm.


I'll take a look. Thanks.


REPL's in PHP are quite hard due to the fatal error issue, among other things.

I wrote one (https://github.com/apinstein/iphp) a long time ago that got around a lot of these issues using temporary files, but his idea to use forking is really neat. I never got multi-line input working, either. I have been thinking about re-doing it with runkit, but now I'll have to play around with BORIS and see how it works.


Very useful tool, partially useful is being able to start a Boris shell mid script:

$boris = new \Boris\Boris('myapp> ');

$boris->setLocal(array('appContext' => $appContext));

$boris->start();

so that you can poke about.


Does it mean that now full PHP support could be added to Light Table?


"There's no chance it can work on Windows, due to the dependency on POSIX features". Too bad.


PHP and Windows are often enough at odds that not having a nice REPL is probably going to be the least of your problems. The other poster is right, bring up a VM and be happy.


Huh? PHP and IIS work perfectly fine together. MS has worked really hard to make PHP a first-class language on their OS. PHP 5.3 and IIS 7.5+ are dead simple to get working. Azure features PHP support as one of their main features.

I've even got a client on an ancient Windows 2000 box running PHP. Took all of an hour to get running. Yes, not the most preferred stack, but they aren't at odds.


If you are using IIS/PHP how interchangeable is that with LAMP? In other words if I develop locally using IIS/Windows can I just drop the same code onto a LAMP server without breaking anything?


There are a few functions that are not available on Windows.

If you hard-code paths in the code that refer to Linux-specific things, it won't work in Windows.

That said, if it works on Windows, it will most likely work on Linux, but a VM should still be favored due to the probability of prod being Linux.


I run PHP on Windows but with the full LAMP static (Apache running on Windows) and deploy to Linux without modification. I suspect you could also do that with IIS (as PHP abstracts the server interface) but I have not tried it.


I just wanted to point out that it unfortunately doesn't work on Windows. And thanks for the suggestions, I am regularly setting up and using VMs already.


just get a VM running linux. If you are to lazy to set up PHP get a pre build stack at http://bitnami.com/stack/lamp


Sometimes I wish Apple had gone with BeOS instead, so that both major desktop OSs wouldn't be native POSIX and thus make developers more aware of portability issues.


It would be better if MS has gone with Posix Standard instead of causing everyone trouble and making proprietary non-standard OS. Portability takes a lot of work, which could've been used to improve the program, instead of trying to get stuff to work with the crappy Windows API. We need less fragmentation, not more. I would hate to write separate programs for Windows, BeOS/Haiku/Mac and *nix.

In my opinion, Unix is much nicer than BeOS. Also, BeOS uses C++, and not all programming languages work nicely with OO. In contrast it is easy to use all languages with C.

Also, why don't you complain when someone makes a program that only works for Windows? There percentage of Unix-only programs is really small compared to number of Windows-only programs.


> It would be better if MS has gone with Posix Standard instead of causing everyone trouble and making proprietary non-standard OS.

POSIX only offers support for command line stuff and daemons. There isn't any GUI POSIX standard, so you only get half-way portability anyway.

Plus anyone with commercial UNIX experience knows that POSIX is like HTML, just because the standard is supported, it does not mean it works the same everywhere.

> Portability takes a lot of work, which could've been used to improve the program, instead of trying to get stuff to work with the crappy Windows API. We need less fragmentation, not more. I would hate to write separate programs for Windows, BeOS/Haiku/Mac and *nix.

Welcome to the 80-90's.

> In my opinion, Unix is much nicer than BeOS. Also, BeOS uses C++, and not all programming languages work nicely with OO.

This is becoming a niche with major OS and compiler vendors slowly focusing on C++.

> In contrast it is easy to use all languages with C.

If the OS has a C ABI, yes.

> Also, why don't you complain when someone makes a program that only works for Windows? There percentage of Unix-only programs is really small compared to number of Windows-only programs.

Because I use computers since 1986 and UNIX used to be just one among many OSs. I only cared about it somewhere around 1994, after an history of several home systems.


I wonder if it would work on cygwin.


No, cygwin won't provide POSIX process features, you need to use something that is not Windows. As others say, use a VM. Unfortunately the hard truth with PHP (and many other languages) is that if you're trying to use Windows as a development environment, you're already starting off at a significant disadvantage. If Windows provided equivalent features in its process model, I'd use them, but AFAIK, it doesn't/can't.


I use Ubuntu on my personal computer and for my side projects, but I'm stuck using Windows at work. In any case, I don't develop in PHP so the question was academic.


Interesting. Even if most of PHP core devs are stuck in another era, the community manages to keep the boat afloat.


What is that other era like, exactly?

Edit: it was an honest question. You casually threw that statement about living in another era out there and get upvoted for it, while I'm being punished for asking you to elaborate on what you actually mean. Is that the PHP hate brigade at work or was there some kind of misunderstanding?


Very pleasant, actually, as long as you get used to people telling you that you're living in another era.


Perl programmers were in another era before you.

Perl - for original hipsters.


Perl - one of the few programming languages that PHP developers are allowed and encouraged to feel smugly superior over.


If you read php internals newsletter there is a sense amongst some of PHP core devs that PHP is "good enough", and those devs are against most innovations, and the fact that nobody knows who can vote in RFC[1] gives them an incredible power.

[1] http://comments.gmane.org/gmane.comp.php.devel/79314


I agree with that. PHP is strongest in areas where it doesn't try to imitate other languages and overload itself on features that are duplicitous or superfluous. The last feature that I really loved and anticipated was functions becoming real objects, it's one of the very few things among recent additions that I think were absolutely essential and overdue. It's also nice that FPM is now part of the default package. There are certainly a lot of areas that could be improved - for example it's incredible how they're still not cleaning up the standard library or some of the parser quirks.


Looks great now I can dump my 60 lines of tape, shoe strings and "I do not have time for this" and use a serious tool.

Thank you.


I looked at it a while ago and it seemed abandoned.

Going to take a stab at using it in WP-CLI: https://github.com/wp-cli/wp-cli/pull/437


Laravel 4 [1] has something called Tinker built in, that lets you interact with your application in a REPL environment.

[1] http://four.laravel.com/


Tinker is a very basic REPL - it has no readline support or error handling - so I've just made a package to add Boris support to Laravel 4.

https://github.com/davejamesmiller/laravel-boris


I can't find anything named tinker in the latest laravel source. Where did you find it?


I can't find any documentation and haven't tested it yet but here's a class for a 'tinker' command in the Illuminate (Laravel) sources: https://github.com/laravel/framework/blob/master/src/Illumin...

'php artisan tinker' on the command line should bring it up.


I wrote this shell script to evaluate php expressions directly inside vim(https://github.com/zweifisch/pipe2eval).


I'm using phpsh as a REPL for PHP: https://github.com/facebook/phpsh

Are there any benefits in switching to BORIS for me?


Brilliant! This seriously needs to be in PHP core.


Looks useful! What does the name BORIS stand for? I see the creator is called Chris...


Maybe the author is a fan. The Wire - "Why always Boris..." http://www.youtube.com/watch?v=JyHuG1ks04A


I can promise Boris has nothing to do with his name. His nickname doesn't sound anything like it either :)


cool, will be useful to sharpen my php skills.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: