phpmetrix for Node.js is a wrapper around phpmetrics that allows for integration with build systems like Grunt, Gulp and more!
npm install phpmetrix> phpmetrix is a node wrapper around phpmetrics that provides integration with build systems like
> Grunt, Gulp and more.





![npm]()
``sh`
$ npm i -g phpmetrix
$ phpmetrix path/to/config.yml
`js
var phpmetrix = require('phpmetrix').phpmetrix
phpmetrix(['path/to/config.yml'], function (err, stdout, stderr) {
if (err) throw new Error(err)
process.stdout.write(stdout)
process.stderr.write(stderr)
// success!
})
`
`json`
{
"scripts": {
"pretest": "phpmetrix path/to/config.yml"
},
"devDependencies": { }
}
`sh`
$ npm test
`js
module.exports = function (grunt) {
require('phpmetrix').gruntPlugin(grunt)
grunt.initConfig({
phpmetrix: {
config: 'path/to/config.yml',
options: {
phpCmd: '/usr/local/bin/php', // Defaults to php
phpmetricsCmd: '/usr/local/bin/phpmetrics', // Defaults to phpmetrics
stdout: true,
stderr: true
}
}
})
grunt.registerTask('test', ['phpmetrix'])
}
`
`sh`
$ grunt test
The same options that can be used in Grunt can be used in Gulp too.
`js
var gulp = require('gulp')
var phpmetrics = require('phpmetrix').phpmetrics
gulp.task('phpmetrix', function (cb) {
phpmetrix(['path/to/config.yml'], function (err, stdout, stderr) {
if (err) {
cb(err)
process.exit(1)
}
cb()
})
})
gulp.task('test', ['phpmetrix'])
`
`sh``
$ gulp test
#### License