Php Extension Serial Port

  1. PHP Serial Extension - Serial port communication extension for PHP. This is a loadable extension for PHP running on Windows implementing serial port handling and. Welcome to my tutorial on Serial Port Communication in VB.Net. Lately Ive seen a lot of questions on how to send and receive data through a serial port, so I thought.
  2. Socket_create_listen (PHP 4 >= 4.1.0, PHP 5, PHP 7) socket_create_listen — Opens a socket on port to accept connections.
  3. How can I access serial port using PHP? If you are using a Windows PC, then - in addition to the problem that PHP's Direct IO Extension cannot be loaded via PEAR.
  4. PHP serial extension test page. I followed the Steps here but the led on Pin 13 just blinks it should stay on when 'light' is written to Serial Port Com6 using.
  5. PHP Serial I somehow got hold of a « Citizen C2202-PD » point-of-sale display, and I wanted to play around with it. I also managed to get the documentation of it, and created a convenience class to access the serial port though the Linux file.
  1. Serial Port
  2. Php Extension Serial Port
  3. Ps/2 Port
  4. Serial Port Monitor
  5. Usb Port
  6. Parallel Port

Serial Port

Active9 years, 2 months ago

I am looking for a way to communicate with RS232 serial COM port on windows. Serial comm with PHP on Windows. Writing my own php extension when I came across.

I'm trying to port the following small QBASIC program (which works 100%) to PHP:

Php Extension Serial Port

Currently I'm calling it in its compiled (exe) form from PHP (on WAMP5) but I'd like to get rid of the QBASIC and call it directly from PHP.

I wrote this PHP function but it just hangs at the fgets() line:


I'm using this PHP line to call the above function:

Any help will be creatly appreciated! I've basically given up trying. If QBASIC can do it perfectly then we must be able to make this work with PHP!

Ps/2 Port

10.1k6 gold badges33 silver badges46 bronze badges

3 Answers

You might want to look into PHP Serial by Rémy Sanchez. There's an article about it here:

Also have a look at this example provided by jared at dctkc dot com on the PHP site:

18.3k2 gold badges33 silver badges62 bronze badges

Pretty sure PHP has no access to hardware ports by default. It has access to network resources, file resources, but without some kind of transport between the hardware and what you're trying to read, can't see this working.

We have 1 free toothpaste fonts to offer for direct downloading 1001 Fonts is your favorite site for free fonts since 2001. Toothpaste font free. Toothpaste is a font based on the idea of a continuous line creating connected script, as if written by a squeezed tube of toothpaste. Every letter and number connects, and there are 48 contextual alternate characters and.

There may however be a platform specific extension you can load which will enable this - just investigating.

Here is the list of HP PSC 1350 All-in-One Printer Drivers we have for you. If you has any Drivers Problem, Just, this professional drivers tool will help you fix the driver problem for Windows 10, 8, 7, Vista and XP. Drivers hp psc 1350 pour windows 7 Then you can download and update drivers automatic. To Download HP PSC 1350 All-in-One Printer Drivers you should Download Our Driver Software of. Just browse our organized database and find a driver that fits your needs.

e: Yep, there is - check this extension, might be what you're after. Without something like this, it's just not going to work.

'This extension allows the direct access the parallel and serial(rs232) port in reading and writing by the DLL inpout32.dll under WIN9x/NT/2000/XP for any assembly. An example of concret application: Complete house automation with web interface and php, connection hardware of any nature with the ports like assemblies simple or to complicate. One idea simple but quite practical.. Extension and source was compiled with Delphi 6 for PHP5.0 to 5.1.2, sources and example included.'

10.1k6 gold badges33 silver badges46 bronze badges

If you're on Linux or other UNX-like system (e.g. Mac OS X), try fopen('/dev/ttyS0') - in UNX, everything is a file, even serial ports. See this for a few tips for finding out which port maps to which 'file'.

73.9k41 gold badges159 silver badges210 bronze badges

Not the answer you're looking for? Browse other questions tagged phphardware-interfaceqbasic or ask your own question.

PHP Serial was written at a time where I did not know any other language thanPHP and I started to get seriously bored with its abilities.

I somehow got hold of a « Citizen C2202-PD » point-of-sale display, and I wantedto play around with it. I also managed to get the documentation of it, andcreated a convenience class to access the serial port though the Linux file.

Afterwards, I posted it to PHP Classes,and this probably is what brought it any visibility.


State of the project

Interestingly enough, this piece of code that is widely untested has created alot if interest ever since it was created, and especially nowadays witheverybody toying around with Arduinos and Raspberry Pis. I receive about 1 emailevery month asking for help with the code or sending patches/suggestions.

I think that it is time for me to remove the dust off this project and to giveit a full visibility on modern tools, aka GitHub.


There is lots of bugs. I know there is. I just don't know which are they.

Platform support

  • Linux: the initially supported platform, the one I used. Probably the lessbuggy one.
  • MacOS: although I never tried it on MacOS, it is similar to Linux and somepatches were submitted to me, so I guess it is OK
  • Windows: it seems to be working for some people, not working for someothers. Theoretically there should be a way to get it done.


I have a few concerns regarding the behaviour of this code.

  • Inter-platform consistency. I seriously doubt that all operations go the sameway across all platforms.
  • Read operations. Reading was never needed in my project, so all the tests Idid on that matter were theoretic. I was also quite naive, so the API isprobably not optimal. What we need is to re-think reading from scratch.
  • Configuration done by calling functions. This is so Java. It would be muchbetter to be able to pass a configuration array once and for all. Furthermore,I suspect that the order of call matters, which is bad.
  • Auto-closing the device. There is an auto-close function that is registeredat PHP shutdown. This sounds quite ridiculous, something has to be done aboutthat.
  • Use exceptions. Currently there is an heavy use of the errors system to reporterrors (2007 baby), but this is seriously lame. They have to be replaced byactual exceptions.

Serial Port Monitor

Call for contribution

I have about 0 time to code or test this project. However, there is clearly aneed for it.

As in all open-source projects, I need people to fit this to their needs and tocontribute back their code.

What is needed, IMHO:

  • Address the concerns listed above, and find new ones.
  • Create a reproducible test environment for each OS, and prove that eachfeature works (basically, unit-testing).
  • Report of use cases, bugs, missing features, etc.

Usb Port

If you feel like doing any of those, do not hesitate to create an issue or apull-request, I'll gladly consider consider it :)


PHP SerialCopyright (C) 2007-2014 PHP Serial's contributors (see CONTRIBUTORS file)

This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.

This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.

Parallel Port

You should have received a copy of the GNU General Public License alongwith this program; if not, write to the Free Software Foundation, Inc.,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Comments are closed.