0
votes

I have a web-based point of sale application on PHP apache. User access the POS from another computer (within the network) to perform the transaction, then print on their local machine. Currently the print format is in html, displayed and printed on the user machine.

I am planning to add support for receipt printer like epson thermal or dot matrix, star. I have searched code escpos php code that might be good for printing to these printers. (https://github.com/mike42/escpos-php)

I read that this script prints locally on server machine or networked printer. But problem is, the printer I am using on the client side only support USB or serial/parallel. How do I send escpos character directly from server to client printer?

2
Their documentation say it supports USB and USB serial github.com/mike42/escpos-php#interfaces-and-operating-systemsJulio Soares
thanks for the reply @JulioSoares, i believe it prints to the server usb. how do i print to the client side usbJackie

2 Answers

2
votes

To be able access local USB deviced via the Webserver would be a huge security risk. Just think of a "evil" server that prints the whole wikipedia on any printer connected to a client, for example.

I don't think that there is a way to access any client-connected USB device with a simple web-based server software. I would suggest either to

  1. get a receipt printer that shows up as a regular printer and just styling your receipts accordingly
  2. write a Thick Client instead or
  3. write a "print-agent" that regularly checks the server if there is any job for the locally connected receipt printer.

Either way, I do not think that, at this point, there is much use for PHP.

You could, of course, try tunneling USB via IP, but that would be quite a hassle to setup and maintain.

0
votes

I know this reply may be too late but I will still leave my answer for anyone that will be needing this in the future.

You can setup a PHP script in your local machine which you can trigger in your remote app once a print button is pressed (maybe via a javascript window open which opens the URL of your local script). That PHP script contains code for printing your receipt using your local thermal printer. You can get the data via API from your remote app. This is somehow somehow a dirty solution but I think this is much safer instead of opening a port just for printing.