PHP.JS: use your favorite PHP functions client-side
phpjs.org
phpjs.org
At another level, I'm always impressed by how PHPers just do it. Whatever it is, you always just seem to get from A to B and have something up and running. You guys are like the weaver ants of the programming world.
edit: I didn't mean to sound so negative. I think this is pretty cool if taken for what it is. Despite the messiness of PHP's libraries, they are well documented and cover a lot. The string, date, and array libraries in particular are quite useful.
This isn't really a way to turn Javascript into PHP. PHP simply has a lot of functions that are handy. Some problems that I can think of are that it brings in PHP's namespacing and lack of naming conventions, but these can be fixed if a developer only incorporates one function at a time when he or she needs it.
That's a part of it, along with some of the kind of weird function semantics, along with just the general idea of "Hey, we should port all the built-in PHP functions to Javascript!" followed by it actually getting done.
If the idea was simply "let's port the useful functions in PHP that makes sense for javascript", that would be one thing. As that idea is actually a subset of this project, no harm done, I guess. Thank goodness we finally have "die" for javascript, right?
On the other hand, I do not need the curmudgeonly array functions. Why anyone would want to recreate the frustrating hell of having to know which array functions are (needle, stack) and which are (stack, needle) is beyond me.
I'm not down on PHP or anything, but much of this seems redundant and a waste of time.
I am wondering how far the code dependencies spread out when you use, say a dozen of your favourite PHP functions, ... Does that force the inclusion of dozens more sub-functions within PHP? Does your compiled file climb towards the all-inclusive 100 KB?
Even if you are concerned about efficiency, it is still excellent as a fast prototyping method, where you get something up and running so you can interact with it, test new ideas, and so on.
The writing style the docs use is also nice. The developers are always referred to as "rock stars", and the examples are always in the form "If you write ..., it could return ...". could return? Nice.
To add something constructive to the debate, I'll just toss in that this goes right in the face of good API design, not as a cheap pun because it's PHP, but because it's a PHP API transliterated into a language not PHP.
I'm particularly interested in the PHP date() function myself, since the date handling in Javascript is seriously insufficient.
P("db_table.name")->filter(function($x, $y){return $x > $y;});