Watchdog

Watchdog is a PHP class implementing inotify which watches for changes to dynamic css files (LESS, SASS, and Stylus) and regenerates their output files on the fly. Specifically, watchdog watches for changes to files in any given number of directories specified in the input. It will not recursively check directories, so you must implicitly specify each directory you want watched. Although it was developed for the purpose of monitoring dynamic css files for changes and auto-regenerating their output, it can easily be transformed into a watchdog for just about anything related to file modifications. For instance, you could automatically log when files are modified or send an email alert.

Watchdog currently supports compilation of Stylus, SASS, LESS, Jade, and HAML. If you have anything else you'd like added to the list, send a pull request!

Fork me on GitHub

Requirements

Watchdog requires you to have the PHP PEAR library inotify installed. If you have PEAR installed, you may run the following from the command line to install inotify:

sudo pecl install inotify

Usage

Example command line usage of watchdog for a variety of types:

You can also create a PHP configuration file for Watchdog. The configuration file is slightly more customizable than specifying arguments via the command line. For starters, you can specify both the input file/directory and output file/directory of watched files/directories which comes in handy if you store your files in two separate directories.

Here's a more advanced configuration file demonstrating all available options:

Downloads

Watchdog is currently hosted on Github.

  • git clone https://github.com/cballou/Watchdog.git
  • git clone git@github.com:cballou/Watchdog.git
  • wget https://github.com/cballou/Watchdog/archive/master.zip
  • wget https://github.com/cballou/Watchdog/archive/master.tar.gz

Support

If you have any problems with Watchdog, please file a ticket/issue/bug on Github and I will attempt to address it at my earliest convenience.

Watchdog Issues on Github

License

Watchdog is licensed under the Apache 2.0 License

Changelog

  • Jun 18, 2012
    Big updates to Watchdog. Added support of ignored files. Added auto-compile of watched files on initialization
  • Dec 9, 2011
    Addition of system level notifications on change events.
  • Oct 31, 2011
    Addition of Jade and HAML handlers.
  • Oct 19, 2011
    Initial commit.

About the Author

is a full-stack web applications developer in Charlotte, NC with 9+ years professional experience. He holds a bachelors degree in Computer Science and has been working remotely since 2012. He specializes in LAMP/LEMP stack development with Laravel and WordPress. Corey is the owner and principal consultant at Craft Blue, a custom web applications development consultancy. He's also the co-organizer of the Queen City PHP meetup group in Charlotte. He is an entrepreneur, blogger, open source contributor, beer lover, startup advocate, chicken wrangler, hydroponics gardening dabbler, and homebrewer.

Corey works with agencies, startups, and businesses.

Contact Corey to see how Craft Blue can help you.