This is setup for Laravel but can work for any app. Most of this is due to the great Laracasts on Gulp

Download and setup gulp

First make a package.json file in the root of your app and just put curly brackets in it.

touch package.json
vim package.json


Then run the needed node commands

npm install -g gulp
npm install gulp --save-dev
npm install gulp-notify --save-dev
npm install gulp-phpunit --save-dev

Now the package.json should look like this thanks to the save switch.

  "devDependencies": {
    "gulp": "^3.6.2",
    "gulp-phpunit": "^0.5.3",
    "gulp-notify": "^1.3.0"

Now to setup the gulpfile, again in the root of your app

var phpunit = require('gulp-phpunit');

var gulp = require('gulp'),
    notify  = require('gulp-notify'),
    phpunit = require('gulp-phpunit');

gulp.task('phpunit', function() {
    var options = {debug: false, notify: true};
        .pipe(phpunit('', options))
        .on('error', notify.onError({
            title: "Failed Tests!",
            message: "Error(s) occurred during testing..."

gulp.task('default', function(){'phpunit');'app/**/*.php', function(){'phpunit');

Basically we are saying watch the app folder recursively for file changes to files ending in php then run all the tests in app/tests/*.php.

Finally run gulp at the command line and it will run keeping an eye on changes.


That is it. From here you will get typically phpunit output as you work BUT also a notice if you break something.