Skip to content

Instantly share code, notes, and snippets.

@mach3
Created March 26, 2014 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mach3/9788084 to your computer and use it in GitHub Desktop.
Save mach3/9788084 to your computer and use it in GitHub Desktop.
Grunt task to run php built-in server
/**
* Grunt Task : phps
* -----------------
* Run php built-in server
*/
module.exports = function(grunt) {
grunt.registerMultiTask("phps", "", function() {
var exec, cmd, options;
exec = require("child_process").exec;
options = this.options({
port: 8080,
host: "localhost",
base: "./",
keepalive: false,
router: null
});
cmd = grunt.template.process(
"php -S <%=host %>:<%=port %> -t <%=base %> <%=router %>", {
data: options
}
);
if (options.keepalive) {
this.async();
}
exec(cmd);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment