Generating large amounts of test data is a common necessity but doesn’t need to be a painful one. We’ve written several custom solutions in the past but have recently come across a web-based Data Generator that takes this further.
Dummy users, addresses, alpha-numeric values, and strings can be created easily through a form. The program isn’t limited by presets: custom data of almost any type can be defined and randomly created with a few clicks.
Once generated, the data can be exported in a number of useful formats, including SQL, CSV, and XML. You can also save your options for use later on.
There are two options to using the program. It can either be installed directly on a LAMP server or you can set up an account for a fee. It’s released as donationware under a GNU license.
Noah
Noah believes that most of the world's problems can be solved with a level head and good software. Though experienced with a number of programming languages, he leans towards opensource because of his belief that knowledge and the tools to express oneself creatively should be freely accessible to everyone.
When testing a new website there are always going to be bugs. As much as we test our programs within our own department, the client will inevitably find bugs. One thing we can do to help solve these situations when they arise is to create an error log.
PHP when installed creates it’s own error log. However, if you are on a shared hosting plan or want to see errors only for a specific site, it makes sense to customize how PHP handles those errors.
The first thing we need to do is setup the function that is going to handle the errors. We will call this myError. This function will take in 4 arguments.
- $errorno – the error number
- $errstr – the text describing the error
- $errfile – the file in which the error occurred
- $errline – the line in which the error occurred
Our function will look like this:
define("LOG_FILE", "/website/path/errorfile.log");
function myError($errno, $errstr, $errfile, $errline) {
switch ($errno) {
case E_ERROR:
case E_WARNING:
case E_NOTICE:
$message = "Error Number: $errno - Error string: $errstr";
error_log (strftime ("%D %T") . " | " . $errfile . " | " . $errline . "n" . $message . "nn", 3, LOG_FILE);
break;
}
}
What we’ve added in there now is the case statement. Basically this specifies what specific errors we want to track. There are a lot of small error types that we don’t need to track. The define statement above defines our constant for the log file location.
Next we need to tell PHP to use this function every time there is an error. We use the set_error_handler function.
set_error_handler('myError');
Notice that the text “myError” is in quotes without the brackets that normally identify a function. This statement would usually be put in an include file that gets executed before each page. Obviously, if we set the error handler after an error happens, it will not be logged.
Of course, this is a very basic error log and won’t always give you all the information you need. You could perhaps add a backtrace to give more information about the error. Implementing our own simple error handler can help us capture those last few remaining bugs which will hopefully prevent any from seeing the light of day or the client.
Jeremy
Jeremy has a love hate relationship with computers , and in contemplative moments he has been known to muse on the fact that his life’s work is in reality a long string of 1’s and 0’s. When he’s not banging code into his keyboard at work, Jeremy is banging out beats for his band “Sad Skelton” that you can check out at www.sadskelton.com.
The Web and Fonts
While fonts are a common and important element of design, translating that concept to the web can sometimes be a challenge. As the web has always had poor font support, there have been a number of ways to work around this. Common solutions are to generate an image using the font, such as with PHP’s GD library or rending a Flash shockwave movie with the font. The problem is that many of these solutions require a specific font format.
While the design world has moved on to the more flexible OpenType format, much of the programming world is using tools that rely on TrueType. Even graphics software giant Adobe has been slow to adopt OpenType in all of its applications, such as Flash CS3 which still only supports TrueType and Type 1.
Enter Font Conversion
Read the rest of this entry »
Noah
Noah believes that most of the world's problems can be solved with a level head and good software. Though experienced with a number of programming languages, he leans towards opensource because of his belief that knowledge and the tools to express oneself creatively should be freely accessible to everyone.

Recently I encountered a situation where I need to run a PHP script in the background. A client requested a YouTube like application where the users can upload a video and it will automatically create a preview FLV flash version. The conversion was to be handled by FFMPEG, an open source piece of software to convert a huge range of audio and video formats.
In order to better get a handle on FFMPEG I downloaded the PHPVideoToolkit. The toolkit abstracts FFMPEG into a PHP class for easier manipulation. I created a script that would use the PHPVideoToolkit to convert the video files into FLV format.
Here is the snag: PHP will not finish executing the script until FFMPEG has finished the conversion. For longer files the browser can sit in it’s “thinking” mode for quite some time until the conversion is finished. This was unacceptable for the situation we were looking where it was unrealistic to expect users to sit there and wait for the entire conversion to take place before they could move on. There needed to be some way to do this as a background process.
exec()
Enter the exec command. This command allows us to run any program that can be run from the command line. The reason we use exec() instead of say passthru(), which also runs the command line, is that with exec() we can specify to take the content of the output buffer and send them to a file. Passthru returns the output right away to the browser. That’s fine if we wanted to run FFMPEG with the super long cryptic command line. How do we do this with our PHPVideoToolkit class though?
php cli
Enter the php command line interpreter (cli). The php command line interpreter allows you to run any php script from the command line.
Now we can create a simple script that uses the PHPVideoToolkit to run FFMPEG. Then we use exec() to run this php script from the command line as a background process.
exec('php convert.php >> convert.log &');
It took me a bit to figure this out as I’m not really a hardcore Linux guy. So here’s the breakdown of the command:
- “php” – invokes the php command line interpreter
- “convert.php” – the name of the php script to run
- “>>” – this specifies where to direct the output buffer. Use ‘>’ to create a new file as opposed to ‘>>’ to append to an existing file.
- “convert.log” – name of the file where output will be directed. You can use “/dev/null” if you want to send the output into a virtual black hole.
- “&” – this is to run the command as a background process
PHP becomes far more versatile when we can run external programs for specific tasks. Allowing us to run them in the background can help to give the user a better experience.
Jeremy
Jeremy has a love hate relationship with computers , and in contemplative moments he has been known to muse on the fact that his life’s work is in reality a long string of 1’s and 0’s. When he’s not banging code into his keyboard at work, Jeremy is banging out beats for his band “Sad Skelton” that you can check out at www.sadskelton.com.