PHP.JS on NodeJS

290 views
Skip to first unread message

Buzzedword

unread,
Aug 2, 2010, 8:15:53 PM8/2/10
to nodejs
Hey guys. I haven't had a chance to play with this, I'm mobile right
now. Anybody hear of a JS library called PHP.JS? Just caught it on
SmashingMag @ http://phpjs.org/

I'm interested as hell, what about you?

Marak Squires

unread,
Aug 2, 2010, 8:17:10 PM8/2/10
to nod...@googlegroups.com
No.


--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Buzzedword

unread,
Aug 2, 2010, 8:25:35 PM8/2/10
to nodejs
Just curious, why?

On Aug 2, 8:17 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> No.
>
>
>
> On Mon, Aug 2, 2010 at 8:15 PM, Buzzedword <dgar...@gmail.com> wrote:
> > Hey guys. I haven't had a chance to play with this, I'm mobile right
> > now. Anybody hear of a JS library called PHP.JS? Just caught it on
> > SmashingMag @http://phpjs.org/
>
> > I'm interested as hell, what about you?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "nodejs" group.
> > To post to this group, send email to nod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .

Marak Squires

unread,
Aug 2, 2010, 8:35:59 PM8/2/10
to nod...@googlegroups.com
1. php has one of the worst apis ever
2. the majority of these functions already exist in much better libraries like underscore or just straight up native in ecma5

to name a few...

To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Timothy Caswell

unread,
Aug 2, 2010, 8:43:35 PM8/2/10
to nod...@googlegroups.com
To be fair, there are some useful chunks of js in there, especially for someone wanting to know how to do something is js that used to work in php.  Though 99% of the function should probably be refactored/renamed/rewritten before using them in a node project.

Buzzedword

unread,
Aug 2, 2010, 8:45:31 PM8/2/10
to nodejs
Oh good god, I didn't see that.

I'm honestly more interested in the project than the usage of it-- Are
developers trying to recreate things like PHP/APACHE with JS/NODE(or
other servers), and would they even bother? I agree dominantly with
your second point.

I don't know, I guess you can say I'm tickled curious about why people
are making libraries like this, you know?

On Aug 2, 8:35 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> 1. php has one of the worst apis ever
> 2. the majority of these functions already exist in much better libraries
> like underscore or just straight up native in ecma5
> 3. things like this :http://phpjs.org/functions/usleep:574
>
> to name a few...
>
>
>
> On Mon, Aug 2, 2010 at 8:25 PM, Buzzedword <dgar...@gmail.com> wrote:
> > Just curious, why?
>
> > On Aug 2, 8:17 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> > > No.
>
> > > On Mon, Aug 2, 2010 at 8:15 PM, Buzzedword <dgar...@gmail.com> wrote:
> > > > Hey guys. I haven't had a chance to play with this, I'm mobile right
> > > > now. Anybody hear of a JS library called PHP.JS? Just caught it on
> > > > SmashingMag @http://phpjs.org/
>
> > > > I'm interested as hell, what about you?
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "nodejs" group.
> > > > To post to this group, send email to nod...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > <nodejs%2Bunsu...@googlegroups.com<nodejs%252Bunsubscribe@googlegroups. com>

Marak Squires

unread,
Aug 2, 2010, 8:49:41 PM8/2/10
to nod...@googlegroups.com
There are a COUPLE of useful ones, MAYBE.

The majority is mostly crap. I would only use this a reference if you really need something like http://phpjs.org/functions/levenshtein:463 or http://phpjs.org/functions/metaphone:863, etc

To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Sami Samhuri

unread,
Aug 2, 2010, 10:23:28 PM8/2/10
to nodejs
On Aug 2, 5:45 pm, Buzzedword <dgar...@gmail.com> wrote:
>
> I don't know, I guess you can say I'm tickled curious about why people
> are making libraries like this, you know?

PHP.js is the result of PHP devs not wanting to know what they were
doing in the browser. They wanted to use the same function names they
were used to from PHP in the browser as well, and just treat JS like
PHP. What could go wrong? :p

PHP.js dumps a whole whack of PHP-ish functions into the global
namespace, complete with inconsistent naming, and inconsistent
argument ordering. You could clean it up and make it JavaScripty and
nice but as Marak pointed out, you'd find that lots of it is just a
thin layer over existing JS functionality, or is already written clean
and nice in libraries such as underscore.js. There's really no reason
to use it unless you're a PHP dev who is scared of learning anything
new. I don't think that applies to anyone here on this list.

-s

Stephen Belanger

unread,
Aug 2, 2010, 11:44:10 PM8/2/10
to nod...@googlegroups.com
I find the stuff on there is more handy to just pick apart and take the useful stuff. For example, I took part of the htmlentities code from there for a project I'm working on, because I didn't remember exactly what all it replaced and couldn't be bothered to look it up. I was at least good enough not to store it globally though, it's stored in a in called str, where I store all my other string manipulation stuff. I had to fix a bunch of stuff though, because I figured out that, in certain conditions, it would replace replace & with &amp;amp; rather than &amp;...apparently it wasn't programmed too well. >.>

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

gf3

unread,
Aug 3, 2010, 12:20:40 AM8/3/10
to nodejs
It's a good example of how not to do things in javascript.
> > nodejs+un...@googlegroups.com<nodejs%2Bunsu...@googlegroups.com>
> > .

Buzzedword

unread,
Aug 3, 2010, 12:50:44 AM8/3/10
to nodejs
Yeah, I definitely only heard of PHP.JS today, and I'm pretty set
against it now after a little bit more digging. Wow. Good looking out.

Peter Hewat

unread,
Aug 3, 2010, 4:43:36 AM8/3/10
to nodejs
+1 ;)

At least this discussion thread made me discover underscore.js which
is interesting indeed :)

kvz

unread,
Aug 3, 2010, 5:27:21 AM8/3/10
to nodejs
Hey Guys,

As the creator of php.js I can probably shed some light on this.

The frontpage of http://phpjs.org does some explaining already. To
summarize:
- We really do encourage people to learn JavaScript (in fact we had to
write a whole bunch of it in order to create php.js : )
- In terms of of highlevel functions JavaScript leaves some things to
be desired like sha1, sprintf, and number_format.

But it's been too much of challenge to stop there.
We figured, instead of us deciding what's made public, let's try to
get at least 2 unit tests from the documentation working, and publish
everything with the occasional warning like: "For study purposes." (as
with mentioned usleep).

To compensate for our huge library with functions ranging from useful
to useless, and that varying from person to person, we let end-users
draw their own line with an online compiler: http://phpjs.org/packages/configure
. "We're all consenting adults here" right? : ) It let's you build
tiny namespaced (yes) packages with just the functions that you need,
and trust. Just take what you need and be on your way. There are
already thousands of different packages out there.

At request by some in the node.js community, we've added CommonJS
support to this compiler http://twitter.com/commonjs/status/12610285557
so that you can export e.g. just the date or cryptographic functions
under a php_js object.

I realize PHP has been getting a lot of heat lately, and we're used to
taking some of that. Especially in JavaScript-land where programmers
often have different server-side backgrounds, it seems like we are
appointed to defend PHP's fame and glory. Well we're not about to.
What I will say is this: it's API is known to get the job done, just
ask millions of developers. And this huge audience is already familiar
with it's quirks. So when they take our stripslashes (like node.js
itself did at one point), we at least bring no new surprises to the
table.

We realize not all functions are perfect yet, and the skill-level of
contributors varies. But chances are, we have a better
http://phpjs.org/functions/strtotime:554 than you could hack up in a
week (although you are an elite programmer). Just because it's being
tested & improved upon by so many people in different environments.
Reporting problems is as easy as making a comment, and 270 different
authors have shared their code, ideas & solutions.
As with any open source project we try to get better & better using
hard labor, unit tests, and encouraging people to contribute better
code.
If you've taken our htmlentities, indeed discovered issues and
improved it with your own fixes, you should really consider
contributing those back.

Best whishes,
Kevin van Zonneveld
http://twitter.com/kvz

On Aug 3, 6:50 am, Buzzedword <dgar...@gmail.com> wrote:

Marak Squires

unread,
Aug 3, 2010, 10:12:23 AM8/3/10
to nod...@googlegroups.com
But chances are, we have a better
http://phpjs.org/functions/strtotime:554 than you could hack up in a
week (although you are an elite programmer). 



Just because it's being
tested & improved upon by so many people in different environments.
Reporting problems is as easy as making a comment, and 270 different
authors have shared their code, ideas & solutions.


270 wrongs don't make a right.


To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Elijah Insua

unread,
Aug 3, 2010, 10:25:01 AM8/3/10
to nod...@googlegroups.com
I dunno, if I had to choose between the two I'd probably go with php.js' strtotime as it 1) doesn't modify Date.prototype or Function.prototype. 2) is CommonJS compatible

-- Elijah

Marak Squires

unread,
Aug 3, 2010, 10:26:27 AM8/3/10
to nod...@googlegroups.com
I hate you tmpvar.

Marak Squires

unread,
Aug 3, 2010, 10:27:47 AM8/3/10
to nod...@googlegroups.com
and as a preemptive response to further discussion on this thread. 

Never argue with an idiot, they drag you down to their level and beat you with experience


/out

kvz

unread,
Aug 3, 2010, 11:22:20 AM8/3/10
to nodejs
Hey Marak,

You'd be surprised to find some pretty bright minds among those 270
authors. Including nodejs contributors on this very mailinglist.
Don't be so fast to serve them all off as idiots.

With 443 functions ported, we have a ton of QA & refactoring to do on
a lot of them. But the popular ones have already evolved to a higher
plan.
I'm confident that it's a matter of time and people such as yourself
stopping by, pointing out actual problems & propose fixes to get all
of them up there.

I like to think that open source is about just that

On Aug 3, 4:27 pm, Marak Squires <marak.squi...@gmail.com> wrote:
> and as a preemptive response to further discussion on this thread.
>
> Never argue with an idiot, they drag you down to their level and beat you
> with experience
>
> /out
>
> On Tue, Aug 3, 2010 at 10:26 AM, Marak Squires <marak.squi...@gmail.com>wrote:
>
>
>
> > I hate you tmpvar.
>
> > On Tue, Aug 3, 2010 at 10:25 AM, Elijah Insua <tmp...@gmail.com> wrote:
>
> >> I dunno, if I had to choose between the two I'd probably go with php.js'
> >> strtotime as it 1) doesn't modify Date.prototype or Function.prototype. 2)
> >> is CommonJS compatible
>
> >> -- Elijah
>
> >> On Tue, Aug 3, 2010 at 10:12 AM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> >>> *But chances are, we have a better
> >>> **http://phpjs.org/functions/strtotime:554*<http://phpjs.org/functions/strtotime:554>
> >>> * than you could hack up in a
> >>> week (although you are an elite programmer). *
>
> >>>http://www.datejs.com/
>
> >>> *Just because it's being
> >>> tested & improved upon by so many people in different environments.
> >>> Reporting problems is as easy as making a comment, and 270 different
> >>> authors have shared their code, ideas & solutions.*
>
> >>> 270 wrongs don't make a right.
>
> >>> On Tue, Aug 3, 2010 at 5:27 AM, kvz <vanzonnev...@gmail.com> wrote:
>
> >>>> Hey Guys,
>
> >>>> As the creator of php.js I can probably shed some light on this.
>
> >>>> The frontpage ofhttp://phpjs.orgdoes some explaining already. To
> >>>> summarize:
> >>>> - We really do encourage people to learn JavaScript (in fact we had to
> >>>> write a whole bunch of it in order to create php.js : )
> >>>> - In terms of of highlevel functions JavaScript leaves some things to
> >>>> be desired like sha1, sprintf, and number_format.
>
> >>>> But it's been too much of challenge to stop there.
> >>>> We figured, instead of us deciding what's made public, let's try to
> >>>> get at least 2 unit tests from the documentation working, and publish
> >>>> everything with the occasional warning like: "For study purposes." (as
> >>>> with mentioned usleep).
>
> >>>> To compensate for our huge library with functions ranging from useful
> >>>> to useless, and that varying from person to person, we let end-users
> >>>> draw their own line with an online compiler:
> >>>>http://phpjs.org/packages/configure
> >>>> . "We're all consenting adults here" right? : ) It let's you build
> >>>> tiny namespaced (yes) packages with just the functions that you need,
> >>>> and trust. Just take what you need and be on your way. There are
> >>>> already thousands of different packages out there.
>
> >>>> At request by some in the node.js community, we've added CommonJS
> >>>> support to this compilerhttp://twitter.com/commonjs/status/12610285557
> >>>> so that you can export e.g. just the date or cryptographic functions
> >>>> under a php_js object.
>
> >>>> I realize PHP has been getting a lot of heat lately, and we're used to
> >>>> taking some of that. Especially in JavaScript-land where programmers
> >>>> often have different server-side backgrounds, it seems like we are
> >>>> appointed to defend PHP's fame and glory. Well we're not about to.
> >>>> What I will say is this: it's API is known to get the job done, just
> >>>> ask millions of developers. And this huge audience is already familiar
> >>>> with it's quirks. So when they take our stripslashes (like node.js
> >>>> itself did at one point), we at least bring no new surprises to the
> >>>> table.
>
> >>>> We realize not all functions are perfect yet, and the skill-level of
> >>>> contributors varies. But chances are, we have a better
> >>>>http://phpjs.org/functions/strtotime:554than you could hack up in a
> >>>> <nodejs%2Bunsu...@googlegroups.com<nodejs%252Bunsubscribe@googlegroups. com>

Marak Squires

unread,
Aug 3, 2010, 11:34:27 AM8/3/10
to nod...@googlegroups.com
You've almost motivated me to release http://github.com/marak/javascript-fu out of spite.



To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.

Joe Developer

unread,
Aug 3, 2010, 12:12:37 PM8/3/10
to nod...@googlegroups.com
On Tue, Aug 3, 2010 at 10:34 PM, Marak Squires <marak....@gmail.com> wrote:
You've almost motivated me to release http://github.com/marak/javascript-fu out of spite.


// removes leading and trailing whitespace from string
exports.toTrim = function( str ){
  return str;
};

quite. 

Marak Squires

unread,
Aug 3, 2010, 12:18:40 PM8/3/10
to nod...@googlegroups.com
?

Marak Squires

unread,
Aug 3, 2010, 12:20:05 PM8/3/10
to nod...@googlegroups.com
what part of unreleased did you not grok?

Stephen Belanger

unread,
Aug 3, 2010, 12:26:03 PM8/3/10
to nod...@googlegroups.com
Yeah, I as going to say--look through the rest of it and you see tons of comments about functions being unfinished. Right in that same file a few lines above you see this aswell;

exports.toPercent = function(number){
  // TODO: add more stripping and formatting logic
  return number;
};

Obviously it's not done yet.

Joe Developer

unread,
Aug 3, 2010, 12:38:35 PM8/3/10
to nod...@googlegroups.com
On Tue, Aug 3, 2010 at 11:26 PM, Stephen Belanger <cyruz...@gmail.com> wrote:
Yeah, I as going to say--look through the rest of it and you see tons of comments about functions being unfinished. Right in that same file a few lines above you see this aswell;


exports.toPercent = function(number){
  // TODO: add more stripping and formatting logic
  return number;
};

Obviously it's not done yet.

Nor is php.js :: We are still trying to port and perfect functions. 


On Tue, Aug 3, 2010 at 9:20 AM, Marak Squires <marak....@gmail.com> wrote:
what part of unreleased did you not grok?
On the same basis, what part of:
We are still trying to port and perfect functions. 
did you not get? 

PHP is largely anathema for me, but that is no reason to disparage the project in such a hypocritical and cunty fashion.

At least you now have 1 line that is not ridiculous hyperbole, congratulations.  

Marak Squires

unread,
Aug 3, 2010, 12:51:36 PM8/3/10
to nod...@googlegroups.com
just added?

updated docs, added warning
Marak (author)
July 15, 2010


magic time machine to july 15th time?

Joe Developer

unread,
Aug 3, 2010, 12:55:44 PM8/3/10
to nod...@googlegroups.com
On Tue, Aug 3, 2010 at 11:51 PM, Marak Squires <marak....@gmail.com> wrote:
just added?

updated docs, added warning
Marak (author)
July 15, 2010


magic time machine to july 15th time?
Marak pushed to master at Marak/javascript-fu 27 minutes ago
  •  ef60bf5 
    Merge branch 'master' of github.com:Marak/javascript-fu
  •  b6062ff 
    updated docs, added warning

    You are the man, dawg. 

Marak Squires

unread,
Aug 3, 2010, 1:07:34 PM8/3/10
to nod...@googlegroups.com
uhhh okay? i added that comment last month. you'll have to forgive me for not pushing changes to github on one of the 100 or so projects i'm actively working on (only a fraction of which exist on github). i'm sorry if i deeply offended you by posting a link to a unreleased project which i don't really have any immediate intentions on finishing and which probably has more watchers then your entire github account. i'm glad you are taking the time to scrutinize things which have little or no relevance to really anything going on in here. if i really gave a shit about that library i would have finished it already, i was merely pointing out other initiatives which have a far superior approach then phpjs. to drill into the specific methods of that approach which aren't implemented / might never get implemented, is just retarded. 


speaking of hypnocritial and cunty.

DO NOT USE PHPJS FOR ANY REASON EVER. ITS THE WORST LIBRARY IN EXISTENCE AND ITS DEVELOPERS ARE TROGLODYTES WHO SHOULD BE LOCKED IN A BASEMENT AND FED $ SIGNS UNTIL THEY SEGFAULT AND NEVER RESTART AGAIN.

PHPJS IS FOR PEOPLE WHO ARE TOO SCARED TO USE ANYTHING BUT PHP

PHPJS IS RESPONIBLE FOR OVER 500,000 DEATHS IN THE UNITED STATES EVERY YEAR

PHPJS RAN OVER MY DOG

PHPJS ATE MY BALLS

Sotonin

unread,
Aug 3, 2010, 1:10:04 PM8/3/10
to nod...@googlegroups.com
Why do you even bother? There's no place for retardedness like this in a programming mailinglist. It's very immature and really does anybody care if you hate php?

Marak Squires

unread,
Aug 3, 2010, 1:14:38 PM8/3/10
to nod...@googlegroups.com
on second thought, i encourage everyone to use this library.

at least that way i'll know who to avoid. 

Marco Rogers

unread,
Aug 3, 2010, 1:25:59 PM8/3/10
to nodejs
I love to see people bite at Marak's troll bait.

@kvz, I tend to agree that there is some good code in phpjs but you
have to search for it. I think it does a disservice to those hidden
gems to package it as "php in javascript". You'll find that the
nodejs/commonjs community is populated with people who have
backgrounds in PHP and are actively running away from it. Regardless
of how "true" it is, the PHP language has a reputation for being
inconsistent and encouraging bad code. Lots of people will actively
try to block that from invading nodejs.

My advice would be to start actively cultivating and cherry-picking
the good stuff, packaging them under nice libraries and releasing them
separate from phpjs. Code is like food in that a lot of the initial
interest is bought with the presentation.

:Marco

On Aug 3, 1:10 pm, Sotonin <soto...@gmail.com> wrote:
> Why do you even bother? There's no place for retardedness like this in a
> programming mailinglist. It's very immature and really does anybody care if
> you hate php?
>
> On Tue, Aug 3, 2010 at 12:07 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
>
>
> > uhhh okay? i added that comment last month. you'll have to forgive me for
> > not pushing changes to github on one of the 100 or so projects i'm actively
> > working on (only a fraction of which exist on github). i'm sorry if i deeply
> > offended you by posting a link to a unreleased project which i don't really
> > have any immediate intentions on finishing and which probably has more
> > watchers then your entire github account. i'm glad you are taking the time
> > to scrutinize things which have little or no relevance to really anything
> > going on in here. if i really gave a shit about that library i would have
> > finished it already, i was merely pointing out other initiatives which have
> > a far superior approach then phpjs. to drill into the specific methods of
> > that approach which aren't implemented / might never get implemented, is
> > just retarded.
>
> > speaking of hypnocritial and cunty.
>
> > DO NOT USE PHPJS FOR ANY REASON EVER. ITS THE WORST LIBRARY
> > IN EXISTENCE AND ITS DEVELOPERS ARE TROGLODYTES WHO SHOULD BE LOCKED IN A
> > BASEMENT AND FED $ SIGNS UNTIL THEY SEGFAULT AND NEVER RESTART AGAIN.
>
> > PHPJS IS FOR PEOPLE WHO ARE TOO SCARED TO USE ANYTHING BUT PHP
>
> > PHPJS IS RESPONIBLE FOR OVER 500,000 DEATHS IN THE UNITED STATES EVERY YEAR
>
> > PHPJS RAN OVER MY DOG
>
> > PHPJS ATE MY BALLS
>
> > On Tue, Aug 3, 2010 at 12:55 PM, Joe Developer <joe.d.develo...@gmail.com>wrote:
>
> >> On Tue, Aug 3, 2010 at 11:51 PM, Marak Squires <marak.squi...@gmail.com>wrote:
>
> >>> just added?
>
> >>> updated docs, added warning
>
> >>>  Marak (author)
> >>>  July 15, 2010
>
> >>>  magic time machine to july 15th time?
>
> >>http://github.com/Marak
> >> Marak pushed to master at Marak/javascript-fu<http://github.com/Marak/javascript-fu/tree/master>
> >>  27 minutes ago
>
> >>    -  ef60bf5<http://github.com/Marak/javascript-fu/commit/ef60bf50973088bd9778474c...>
>
> >>    Merge branch 'master' of github.com:Marak/javascript-fu
>
> >>    -  b6062ff<