Middleware to handle PHP

var gateway = require('gateway');
var phpGateway = function (dir){
    return gateway(require('path').resolve(dir), {
        '.php': 'php-cgi'
    });
};

Add middleware call to livereload in connect options:

connect: {
    options: {
        port: 9000,
        // change this to '0.0.0.0' to access the server from outside
        hostname: 'localhost'
    },
    livereload: {
        options: {
            middleware: function (connect) {
                return [
                    lrSnippet,
                    phpGateway('app'),
                    mountFolder(connect, '.tmp'),
                    mountFolder(connect, 'app')
                ];
            }
        }
    },
    test: {
        options: {
            middleware: function (connect) {
                return [
                    phpGateway('app'),
                    mountFolder(connect, '.tmp'),
                    mountFolder(connect, 'test')
                ];
            }
        }
    },
    dist: {
        options: {
            middleware: function (connect) {
                return [
                    mountFolder(connect, 'dist')
                ];
            }
        }
    }
},

To the watch task config options, add the php extension to the livereload:

livereload: {
    files: [
        '<%= yeoman.app %>/*.php',
        '<%= yeoman.app %>/*.html',
        '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
        '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
        '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,webp}'
    ],
    tasks: ['livereload']
}

To install npm module:

npm install gateway --save-dev

Reference: