Tom Butler's programming blog

NoF5 Web Development Tool

No longer wear out your F5 key! This simple PHP script will let you avoid refreshing the browser each time you change a file!

Pre-requisites

  • Linux server (but you can view the page in a Windows/Mac browser)
  • The strace utility (included with almost every Linux distribution)
  • The user running PHP must have access to run strace
  • A browser that supports server-side events e.g. Chromium or Firefox

Usage

1) Include nof5.phar at the top of your script.

require_once 'nof5.phar';

2) Save a file on the server and your browser will be updated as long as the page you're viewing has a <head> tag!

Features

  • For CSS and JavaScript files, the CSS will be reloaded without refreshing the page. If you have any JavaScript created elements/menus visible they will just be styled with the updated CSS without needing to be regenerated
  • For JavaScript files, the javascript is reloaded in-place meaning the entire browser isn't refreshed!
  • Any server-side file used by the page (Which includes any xml files, template files or any other file the script has opened), when written to will trigger a browser refresh.

Download NoF5.phar or View the source code on GitHub

Windows support?

It would be good if this supported windows, however I don't have a Windows PC to test on. If anyone knows of an equivalent utility to Linux's strace for monitoring file access, it could be used to implement a Windows version.