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.
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?
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.
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.
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.
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.").
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!
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.
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?
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.
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.
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.
The subject of PHP reminds me of this (possibly untrue) story: a guy is whacking his own manhood with a hammer and someone asks him: "Why are you doing this?", to which he replies "For pleasure". When the other guy continues asking "But when do you feel the pleasure?" the first guy says "When I stop".
48 comments
[ 10.2 ms ] story [ 137 ms ] thread> 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.
Anybody knows of a debugger equivalent to ipdb (python) / pry (ruby) for php to allow live debugging stuff on the server?
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'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 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.
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.
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.
Thank you.
Are there any benefits in switching to BORIS for me?
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!
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.
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?
Perl - for original hipsters.
[1] http://comments.gmane.org/gmane.comp.php.devel/79314
$boris = new \Boris\Boris('myapp> ');
$boris->setLocal(array('appContext' => $appContext));
$boris->start();
so that you can poke about.
Going to take a stab at using it in WP-CLI: https://github.com/wp-cli/wp-cli/pull/437
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.
[1] http://four.laravel.com/
'php artisan tinker' on the command line should bring it up.
https://github.com/davejamesmiller/laravel-boris