Search code examples
phpnode.jsgruntjsphpcodesniffer

PHP Code Sniffer via Grunt is incredibly slow


I'm having issues with PHP Code Sniffer running inside of a Grunt task.

Everything has been freshly installed. PHP CS runs perfectly from the terminal (run in less than 2 secondes). But when I run it thought a Grunt task (same binaries, config file, params,etc..) it takes over a minute. I tried using grunt-phpcs and grunt-exec (even tried using a subshell $()) always the same result...

Execution Time (2016-05-26 00:09:21 UTC)
loading tasks    956ms  ▇▇ 2%
exec:phpcs     1m 0.7s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 98%
Total 1m 2s

I'm on El Capitan, using node 5.11, grunt 1.0.1.

Any idea?


Solution

  • You need to adapt the default_socket_timeout in the php.ini for your PHP CLI. This has worked for me:

    default_socket_timeout = 0
    

    See also http://php.net/default-socket-timeout and https://github.com/nodejs/node-v0.x-archive/issues/3627.