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

This entry was posted in Cool Feature and tagged , , , , , . Bookmark the permalink.

3 Responses to File Watchers in PhpStorm

  1. ByRad says:

    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 says:

      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 says:

      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)).

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>