Hoopla!

now with extra whiz-bang!

Hoopla!

Automatically checking for php parse errors

July 27, 2006 · 0 comments

I’ve been running into a problem on one of my multi-developer sites where we’ve been unable to break the habit of occasionally allowing parse errors to show up on one of our php sites. We mean well, we try to avoid it, but sometimes a quick fix is necessary and we don’t always have time to do testing (it should be noted that we don’t have a testing harness of any kind for this site).

Just last weekend I was horrified to find that I’d left a parse error in a small, seldom-visited part of our site for several days. No users encountered it but it prevented some automated tasks from working as they’re supposed to.

It’s become clear that we need more than just to try harder – we need technology to watch our backs. Do accomplish this I’ve developed a bash script that takes directories as arguments and has php parse the contents of every php script in that folder’s structure.

The Code: -
#!/bin/bash

check_dir() {
  for file in $*/*.php
   do
    if [ -d $file ]; then
      echo "going into $file" 
      check_dir $file
    else
      if [ "`php -l $file`" = "No syntax errors detected in $file" ]; then
        echo "valid in $file" 
      else
        echo "$file invalid" 
      fi
    fi
  done
}

for dir in $*
 do
  check_dir $dir
done

It’s very simple – but it’s all that’s required to get started. From here I’m going to replace the echo’ed output with tasks. Specifically, a php file will be run when files are found to be invalid and both an email and an SMS will be sent to the developer’s phones.

We’re setting this script to run every 5 minutes, hopefully no weekends will pass from now on without being error- (at least parse error-) free.

→ 0 comments Tags:

How to Launch a Website

May 29, 2006 · 1 comment

I wrote out a lengthy essay before I realized this is a rather straightforward endeavor. The how to’s of launching a (successful) website are simple and few. I’ll make this short. In fact, I’ll make it a list.

How to Launch a Website:

  • Make something that has value to a certain, specific group of people
  • Release it as soon as you have the minimal amount of functionality required for it to work.
  • provide your users with an easy way to contact you
  • Listen very closely to what your users tell you (and respond!)
  • Surprise your users with your candor
  • Surprise your users with innovative new changes shortly after launch
  • Never (NEVER) allow data that your user has added to the site to become lost or irrelevant.

That last one especially. You can have all the bugs in the world and the users will understand – unless you make them fill out the same form twice. That’s unforgivable.

→ 1 comment Tags: