php

phplint

Lightning fast concurrent PHP linter for Node.js, Grunt & Gulp! ⚡️

Showing:

Popularity

Downloads/wk

4.4K

GitHub Stars

61

Maintenance

Last Commit

7mos ago

Contributors

9

Package

Dependencies

3

Size (min+gzip)

26.7KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Reviews

Average Rating

4.0/51
Read All Reviews
TomGalla11

Top Feedback

1Great Documentation
1Slow

Readme

phplint

phplint is a node wrapper around the native php linter that allows for parallel linting and integration with build systems like Grunt, Gulp and more.

Build Status npm styled with prettier

Usage

CLI

$ npm i -g phplint
$ phplint '**/*.php'

Paths and filenames are parsed using globby, so the following would work as well:

$ phplint '**/*.php' '!vendor/**'

Node

var phplint = require("phplint").lint;

phplint(["src/**/*.php"], function (err, stdout, stderr) {
  if (err) throw new Error(err);

  process.stdout.write(stdout);
  process.stderr.write(stderr);

  // success!
});

NPM

{
  "scripts": {
    "pretest": "phplint 'src/**/*.php'"
  },
  "devDependencies": {
    "phplint": "~1.0.0"
  }
}
$ npm test

Grunt

Configure cache directories

This module uses the cache-swap module to cache already linted files. You can configure the cache directories via the cacheDirName and the tmpDir options. Both options will be passed to the CacheSwap instance when created.

module.exports = function (grunt) {
  require("phplint").gruntPlugin(grunt);

  grunt.initConfig({
    phplint: {
      options: {
        limit: 10,
        phpCmd: "/home/scripts/php", // Defaults to php
        stdout: true,
        stderr: true,
        useCache: true, // Defaults to false
        tmpDir: "/custom/root/folder", // Defaults to os.tmpDir()
        cacheDirName: "custom/subfolder", // Defaults to php-lint
      },
      files: "src/**/*.php",
    },
  });

  grunt.registerTask("test", ["phplint"]);
};
$ grunt test

Gulp

The same options that can be used in Grunt can be used in Gulp too.

var gulp = require("gulp");
var phplint = require("phplint").lint;

gulp.task("phplint", function (cb) {
  phplint(["src/**/*.php"], { limit: 10 }, function (err, stdout, stderr) {
    if (err) {
      cb(err);
      process.exit(1);
    }
    cb();
  });
});

gulp.task("test", ["phplint"]);
$ gulp test

License

MIT © Wayne Ashley Berry

Rate & Review

Great Documentation1
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow1
Buggy0
Abandoned0
Unwelcoming Community0
100
TomGalla1118 Ratings140 Reviews
Passionate frontend and backend developer. 24/7⏰
1 year ago
Great Documentation
Slow

I think this is one of the best and simplest PHP linter. I using it for all my projects. But sometimes the PHP linger is a little bit slow. But in general, this linter is good.


0

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial