RS-232 (serial port) and PHP under Windows

Unlike Flash or JavaScript, PHP is not sandboxed and might therefore look like an acceptable choice when trying to communicate over RS-232. After briefly looking into it, I wouldn’t recommend it for production systems. Anyhow, here are the options I found:

1. DIO Direct I/O functions

The DIO functions have not been bundled with PHP for years,  but you can download the DIO Package here (it’s still in beta). The following article contains instructions on how to install and use it: How do I control a serial port using PHP? The required php_dio.dll file is available for PHP up to version 5.6, though the PHP manual says that the DLL is “currently unavailable” (which is true if you’re using PHP 7).

On a Linux system, according to what I’ve read, the DIO extension is probably the best way to use a serial port with PHP.

2. PHP Serial class (a.k.a php_serial)

The current version can be found here. “There is lots of bugs”. On Windows, “it seems to be working for some people, not working for some others.” Good luck.

3. Serial-to-Network Proxies

You’ll find many of these proxies on Arduino Playground, including useful descriptions. They are written in languages better suited for the task (well some of them are) and act as intermediaries between serial and network connections. In PHP, you’d simply connect to the socket provided by the proxy (careful, some are unidirectional). This option might be your best bet on Windows, but obviously makes things more complicated.

This list is not exhaustive, but at this point I decided to abandon the entire idea. Don’t hesitate to post your solution in the comments if you’ve found one that isn’t listed. However, please don’t bother asking me any PHP-and-RS-232 related questions as I won’t be able to answer them.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.