File Watchers in PhpStorm

Imagine working on a file and running a command line tool in the background for every change made. “Why would I want that?” I hear you say. Wouldn’t it be great if the IDE could minify our JavaScript and CSS files on the fly? Or compile CoffeeScript into JavaScript?

That’s exactly what File Watchers allow us to do!


This functionality is available in IntelliJ IDEA, PyCharm, WebStorm, PhpStorm, RubyMine and AppCode.

This functionality is available in IntelliJ IDEA, PyCharm, WebStorm, PhpStorm, RubyMine and AppCode.

Note for some IDEs we will have to download and install the File Watchers plugin to use this functionality (available for free). The plugin comes bundled with WebStorm and PhpStorm.

When PhpStorm detects that you are working in a type of file it can “watch,” it will prompt us to set up a File Watcher. Here’s an example of that when working in a .less file:

Clicking Add watcher will configure PhpStorm to transform the LESS code we are working on into CSS. And we can do the same with tools like YUI CompressorClosure CompilerTypeScript and CoffeeScript compiler and many, many more.

Eager to learn more about how this all works? Have a look at the full tutorial on File Watchers. Or If you are more into watching a video, that’s possible too.

Let us hear your thoughts in the issue tracker, through the comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

About Maarten Balliauw

Maarten Balliauw is a Developer Advocate at JetBrains, working on .NET tools. He focuses on .NET, Azure, web technologies and application performance. Maarten is a frequent speaker at various national and international events. In his free time, he brews his own beer. Follow him on Twitter or check his personal blog.
This entry was posted in Cool Feature and tagged , , , , , . Bookmark the permalink.
  • ByRad

    It would be great if File Watchers allows to automatically invoke some custom stript on terminal, this would be nice feature eg. when editing server side files that are beeing cached in Apache running on another machine to run custom script that clear any cache, session files and temporary files.

    • Les Harris

      You can always configure a custom filewatcher to execute anything you want. Because the custom type exists there really is no limit to what you can have automatically executed when files change.

    • Andriy Bazanov

      Create custom shell/batch/whatever script that does such job and just use it as File Watcher (yes, it has to be your script who will connect to that remote machine and issue a command(s)).