Fork me on GitHub

Learn how to do it in JavaScript. Explore boundaries porting languages. Enjoy functions that turn out to be useful.

Coding Style

Given the focus of php.js I think we should re-invent as few wheels as possible and make use of sensible tools and standards that are other people have already invested a great deal of time in to get right.

In this light, I’ve decided to adopt Felix’ Node.js Style Guide for coding standards, instead of running our own.

It saves us time maintaining and it becomes easier for people to contribute because they don’t have to memorize where php.js diverges.

For the big parts our codebase is already compatible with it, so we won’t get any weird space + tab indentations as a result, as we start adding code that follows the guide.

Going forward, contributions should comply with these conventions before being merged in.

Best wishes,

Kevin

A Word on the Focus of php.js

Hi everybody,

The new site has no server-side code. Instead we generate HTML using Octopress and push to GitHub Pages, all from one repository.

This saves hosting costs/overhead and makes it really easy for people to submit pull requests and for contributors to make changes that I don’t always have time for. It makes the project less dependent on me and more a community effort.

To move forward, sometimes you have to cut features. In this case I had to lose our compiler, a webtool that relied on server-side code to generate minified packages from php.js functions.

Understandibly this has raised questions. It is still possible to bundle 4 useful functions:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# - Note that this combined 4 php.js functions into a file called: myphp.js
# and minified version: myphp.min.js in the current directory.
# - Note that this throws all functions into the
# global scope. It would be better to put them in a dedicated phpjs object.
curl -sk https://raw.github.com/kvz/phpjs/31bf3129f08672f8c1d6d0dcad2368ebc4ac57f2/functions/\
{datetime/date\
,datetime/strtotime\
,strings/md5\
,strings/vsprintf\
}.js |tee ./myphp.js && \
curl -vo ./myphp.min.js \
    -X POST \
    -H 'Expect: ' \
    --data-urlencode compilation_level="SIMPLE_OPTIMIZATIONS" \
    --data-urlencode output_format="text" \
    --data-urlencode output_info="compiled_code" \
    --data-urlencode js_code@myphp.js \
    http://closure-compiler.appspot.com/compile

but some people think php.js should bundle all of it’s functions into one big file:

Not providing an all-in-one, downloadable, minified, ready-to-use .js file is going to kill php.js. You’ve abandoned windows users, and really any non-CLI junkie. While I am capable of compiling this myself, what a headache. You’ve introduced a barrier-to-entry that didn’t exist before, and by not existing, allowed for the following you now have. I highly suggest that you have this available for download, either here or on github, such that you can keep (and maintain) the momentum you worked so hard for.

I’d like to comment on that here. While I appreciate the sentiment, wether the project is being killed by these changes depends on how you look at php.js. To me, php.js is a resource:

  • For PHP developers that want see how it’s done in JavaScript
  • That enables fun experiments
  • With a few higher level functions that are incredibly useful, and missing in JavaScript

This is what I feel php.js should focus on. Making functions. Making them better.

If - on the other hand - you think of php.js as a

  • 2.1MB, 451-function, ready-to-rock spaceship that you can plug into your website so you can keep typing PHP client-side, not caring about learning JavaScript or how that extra weight might impact the user experience

..then yes, these changes are going to kill php.js.

I have limited time to spend on open source, and I want to spend it on things I enjoy and can believe in. Not on working to support use-cases that keep new developers from learning, or make the web slower. I’m sorry if this upsets folks but it really is my free time.

Luckily though for people with different views, I released php.js under MIT so it’s cool for anybody to fork this project and run with it.

If anything, knowing that the php.js repository will focus on the raw ./functions makes this easier.

Best wishes,

Kevin

New Site

Hi everybody,

Welcome to our new site. The old one had a lot of dead weight that nobody used and was basically unmaintained.

This one is generated by Octopress as plain html, and then stored on Github pages.

The source to do that is inside the php.js directory in the _octopress dir, and freely available.

For instance, you can now very easily:

Next, any php.js contributor who has Octopress set up (this mostly involves having the right ruby & gem versions) can then run make site MSG="describe what you did" in the project’s root dir to deploy the changes.

This should make it easy for php.js contributors (or any Github user really, using pull requests) to update the site, making it less dependent on few core members, and more a community effort.

This is also the way I want to do regular php.js development. Less via comments, more via the power of Github.

To people wondering where the compiler has gone to, I’m discontinuing that feature. It was more often broken then working, and I think this site should focus on being a simple resource and discussion platform, and not much else.

Now that everything is open sourced more I think there’s room for anyone to build a better alternative.

While I’m not actively involved with php.js anymore, I hope taking this step will make the project ready for the future.

Best wishes,

Kevin