I also needed to get to the serial ports but in php.
Download serproxy from freshmeat.net and use the software to turn your ttys0 (com1) etc into sockets.
Once they are sockets the standard commands in php will work fine.
ex: fputs($fp, "QUIT\r\n");
For more info on sockets see WROX "Professional PHP Programming" ch 16 PHP Connectivity