Last month there were at least two enquiries at the Bangalore PHP UG on how to get PHP to communicate with the server’s serial port. I didn’t think it was possbile, but here’s what a quick google search turned up:
PHP Serial Extension:
This PHP extension for Windows allows you to communicate directly with the serial port through PHP.
This is a loadable extension for PHP running on Windows implementing serial port handling and communications. Once installed in PHP environment you can programm PHP applications to control serial device hosted on server from remote location; these devices can be anything from video switcher, cameras pan/tilt, ham radios, media players, home automation boxes, GSM modems/terminals (send/receive SMS), only your imagination and needs are the limits.
Link: http://www.easyvitools.com/phpserial/index.html
Link to installation instructions and usage: http://www.easyvitools.com/phpserial/php_ser_reference.html
PHP Serial Class
If you’re a solution in Linux, here’s the PHP class you’re looking for. PHPClasses.org has a PHP Serial Class which allows you interact with your serial ports in Linux
This class can be used to communicate and configure peripherals connected to a serial port under Linux, simplifying the development of applications that need access serial devices. It takes the path of serial device and checks whether it is valid before opening a connection to it. Once the connection is opened, it can send data to the serial port. The class may also change connection parameters for the given serial device.
Link: http://www.phpclasses.org/browse/package/3679.html
If you’ve used any of these solutions for your applications, do let me know your feedback.

Attaining qualifications like 642-425 and 642-432 make one go for 642-444 and 642-511 as well.

Rémy Sanchez on April 9, 2007
Hello,
I wrote the phpSerial class, so I could test serial port through PHP. It is working realy fine for controlling a customer display. I am writing additional components for the class in order to be able to read the serial port and use it under windows.
I will be pleased to answer to questions, as far I can ^^
vinu on April 10, 2007
Thanks Rémy. We’ll be interested to get any updates to your class, especially the ability to read from the serial port.
developercast.com » Vinu Thomas’ Blog: PHP and Serial Ports on April 16, 2007
[...] a recent post to his blog, Vinu Thomas posted about a PHP extension that allows your scripts to directly interact with the serial ports on the web [...]
NotÃcias e links - 03/05 « PHP-BR on May 4, 2007
[...] PHP and Serial Ports [...]
Rémy Sanchez on June 2, 2007
I just released my new version. Adds :
- Support of windows
- Easy configuration of serial port
- Reading (linux only)
vinu on June 2, 2007
Thanks for the update Rémy.
wayne hutchison on June 16, 2007
Dear Remy:
)
I am developing my own open source home automation/robotics system. I currently use Apache/PHP/Serial Extender in Windows, but need to port all to Linux/Debian/Slackware.
Could you show me how to use your php_serial.class in PHP?
I need to send/receive characters from Web page to serial port. Any help would be greatly appreciated
Sincerely,
Wayne Hutchison, VoX Automation, LLC
vinu on June 18, 2007
Wayne,
You can contact Rémy over at:
http://remy.is-a-geek.org/moi/
stonicus on July 6, 2007
Awesome class. How soon before you’ll have read capability for Windows?
Rémy Sanchez on July 25, 2007
Thanks for the “awsome” =D
But I don’t think I ever manage to get reading for windows… I already tried a lot of different functions, and each time it acts as if the stream was empty… So for a pure PHP implementation I don’t think it is possible (or maybe on win 9x only, but actualy I have no time for testing it).
Maybe you can connect to some serproxy server instead
Ilya on August 18, 2007
Hello!
Great class! One problem though that I couldn’t find a solution for.
When I receive a response back from the RS-232 device I communicate with, for some reason my script
(utilizing the serial class) echoes every character of the response back to the serial device.
E.g. when I connect to the serial port with hyper terminal and send a command to it — it works fine, but when I type something back on the hyper terminal I get every single character echoed back — so that have 2 symbols for each one I type on the screen if the local echoing is on and
just 1 symbol for each one I type if the local echoing is off.
Could anyone please tell me what I need to do to disable the echoing back? I’d really appreciate your help.
Thanks!
Rav on March 15, 2008
Hey.. this isn’t working for me.. I am using Fedors core 4.. I tried to connect thru Stty1 and it does nothing…. no error msg too..
Lara on March 17, 2008
Hi
I need to send some data to a printer conected to serial port (com)
and i wnat know the function in PHP that did this operation
Thanks
Mike FIeld on March 18, 2008
Hi,
I am able to read/write to a serial port under windows with nothing more exotic than the code below. I am just working on exec()ing a ‘mode’ command to set the port speeds and so on.
Mike
<?php
function readInput($f,$t)
{
$i=0;
$buffer = “”;
while($i “.$buffer;
}
error_reporting(E_ALL);
$f = fopen(“COM4″,”r+”);
if(!$f)
{
die(“Unable to open serial port\n”);
}
$i=0;
fwrite($f,”Hello\r\n”);
while(true)
{
fwrite($f,”AT-”);
sleep(1);
readInput($f,5);
fwrite($f,”AT+CMGF=1-”);
sleep(1);
readInput($f,5);
fwrite($f,”AT+CMGW=\”0212266816\”-”);
sleep(1);
readInput($f,5);
fwrite($f,”AT+CMSS=1-”);
sleep(1);
readInput($f,5);
$i++;
}
fclose($f);
?>
EDWINSPIRE on April 21, 2008
Saludos:
He programado en PHP un software que permite comunicarse con el puerto serial, enviarle un comando AT y leer su respuesta.
El software esta diseñado para enviar y recibir SMS tanto en formato PDU como en modo Texo.
Para mas informacion y descargas visiten edwinspire.890m.com hagan clic en PROGRAMACION PHP
Translation (google translate):
Hello!
I programmed a PHP software that allows you to communicate with the serial port, send an AT command and read its response.
The software is designed to send and receive SMS in either mode as PDU Texo.
For more information and downloads visit edwinspire.890m.com click on PHP Programming
alfredo on May 15, 2008
hey mike fleld
I think your code is incomplete in
function readInput($f,$t)
{
$i=0;
$buffer = “�;
while($i “.$buffer;
}
can you check it and post again
Ever on May 17, 2008
Hi everybody!! I was wondering if some could help me! I need to make a button that sends something trough the serial port without having to refresh all the web page. Something that u click and u see an inmediate reaction in the port. Thanks. Anything would be usefull!
edwinspire on May 19, 2008
Saludos nuevamente:
Quiero comunicarles a las personas que visitan el foro y buscan informacion acerca de PHP, PHP-GTK2 y/o comunicacion con el puerto serie desde PHP pueden comunicarse conmigo a mi email.
Esta disponible el nuevo codigo fuente de la Aplicacion PHP_GSM, para descargarla en http://edwinspire.890m.com
Hay dos versiones:
- 1 – Una integramente hecha en PHP (Pero en las pruebas realizadas bajo windows se ha notado un alto consumo de memoria RAM y algo de lentitud en la ejecucion del programa.)
- 2 – Otra version donde la parte correspondiente a la comunicacion con el puerto esta Programada en C, el resto del programa sigue escrito en PHP (Con este cambio se noto una mejora notable en el desempeño del programa)
Probado unicamente con el Motorola L6i sin ningun problema, y diseñado tanto para Win como para LINUX.
Rod on June 13, 2008
I would like to know if you have documentation on how to implement communication with customer display for a POS project im working on. Are the commands etc different from manufactures? where can i get the commands, etc sample will be great thanks.
B Karthick on July 24, 2008
Dear Rod,
Usually the manufacturer supplies code (in C, Java and VB). It may work with small modification for all Displays.
Tracker on September 11, 2008
Hello. Has anyone seen or heard from Rémy Sanchez? The class has an error line 503 and Id like to know more about it. There is no documentation for the class and his personal website has vanished.
vinu on September 19, 2008
Tracker,
You can get the contact details for Rémy Sanchez from the phpclasses site:
http://www.phpclasses.org/browse/author/428373.html
John on January 31, 2009
Hey, just wondering is there any way of reading serial port with windows, help
Thanks
vinu on February 3, 2009
There seems to be a third party component called ActiveComPort which allows you to communicate with Serial Ports in Windows.
http://www.activexperts.com/activcomport/
Here’s their PHP example:
http://www.activexperts.com/activcomport/howto/php/
G-Land on October 12, 2010
Thanks Rémy. We’ll be interested to try the class, especially the ability to read from the serial port.