New PHP Linter with plain JS



I would like to share with you my recent project - it’s a PHP linter addon fully written in JS (without any ajax request).

You can try the demo here :

If you have ideas or want to contribute you are welcome on github :slight_smile:


I would love to have something like this in my editor, ICEcoder. However, I’ve looked into this before and found the same thing as you - the lint file to define all PHP words makes for a huge JS file, in your case 119kb. It’s very nice to have linting for this in the gutter, but is quite a big file to load.

PS - why are exit and die bad? I have to use them quite a bit in setups such as cron tasks, APIs etc and can’t find any info online supporting the theory that they’re bad.


I ran the php-parser.min.js file through Google Closure Compiler and it further minified it from 119kb to 97kb. Try it yourself at: Still kinda big tho.

Aside from concerns about its size, it does seem to work really well and love that you’ve covered PHP 7. Did you use at all to help with this?


Hi mattpass, thanks for sharing icecoder, it’s great !

You’re right, here size matters. It’s not a simple regex based linter, but a strict tokenizer and AST builder parser that sticks to PHP lang specification, so the implementation is quite huge.

I’ve used various sources, the grammar file,,

I can maybe gain 10% by avoiding to use browserify and requirejs. In order to gain more (about 10 to 20%) I should replace every named token to its constant value.

With a customized concat/minifier I can maybe be between 50kb to 70kb - but it will still be a huge dependency.

For die and exit it’s just for fun, you can disable it options, but you may want to avoid this if you try to lint an external module (same for print_r, var_dump or eval) …


Thanks, its what happens when you take CodeMirror integration a little too far LOL

I can talk to you about this on your GitHub repo I think (rather than here at the CodeMirror forum), but if it at all could be a standalone file of 50-70kb I’d be very interested in making it an ICEcoder plugin (as per JS Hint etc). Alternatively, if it ends up in CodeMirror as an addon at a reasonable size (?) I’d certainly make use of it from the repo.

It works really well from what I can tell from testing! Kudos! :smiley:


Not sure it will be under 50kb, but 70kb should be feasible - I’ve started an issue here :