More info at: http://phpjs.org/about
$ mkdir test && cd $_ $ npm install phpjs $ $EDITOR try.js
var php = require('phpjs'); php.echo(php.sprintf('Hey, %s : )', 'you')); php.echo(php.parse_url('mysql://kevin:firstname.lastname@example.org/databasename')['pass']); php.echo(php.strtotime('2 januari 2012, 11:12:13 GMT'));
$ node try.js Hey, you : ) abcd1234 1325502733
node bin/phpjs.js --action test --name sort node bin/phpjs.js --action test --category array
PORT=8080 node test/browser/server.js
Point your webbrowser to http://localhost:8080
We keep the website in
./website for so it's easy to keep docs & code in sync. For those reading this screaming murder, HashiCorp does this for all their projects, and it's working pretty well for them on a scale more impressive than ours.
Our website is built with Jekyll.
Here's the flow that takes written functions to the website:
npm run website:injectruns
lib/phpjsutil.jsto parse them, most significantly: the header comments that declare authors, tests, and dependencies
injectwebthen writes each function to
website/_functions. This is a Jekyll Collection. The code is written as the content, and all the other properties are added as YAML front matter
- Jekyll uses
website/_layouts/function.htmlas the layout template for the function collection, this determines how all the properties are rendered.
Blog posts can be found in
At the time of writing, the Jekyll Asset pipeline is in a bad place, and so SASS / ES6 asset transpiling is handled separately via npm scripts. Unfortunately we don't have the theme of the website in SASS, so it's included in
app.scss as plain CSS for now. You can find all the transpiling options in
npm run website:deploy in the root of the project takes care of all the building steps above, and then force pushes the generated HTML to the
gh-pages branch of this repo.
- Split out the npm module so you could do
var sprintf = require('phpjs/sprintf')
- Auto-deploys via Travis CI