0

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?

Jackie
  • 494
  • 7
  • 14
  • Their documentation say it supports USB and USB serial https://github.com/mike42/escpos-php#interfaces-and-operating-systems – Julio Soares Oct 12 '15 at 09:36
  • thanks for the reply @JulioSoares, i believe it prints to the server usb. how do i print to the client side usb – Jackie Oct 12 '15 at 10:00

2 Answers2

2

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.

Franz Gleichmann
  • 3,420
  • 4
  • 20
  • 30
  • 1
    thanks for suggestion, i will give it a try with 'thick client' which i did before by having php apache running at client and a simple script to do the job. I'm still exploring for simple or proper way if possible avoid additional installation. Other method I read is using java applet, which i avoid due to applet signing issue i might encounter in future, also technically i'm not so familiar at it. – Jackie Oct 13 '15 at 03:31
  • 1
    If you DO want to write your thick client with php, you could look into [phpdesktop](https://code.google.com/p/phpdesktop/), which basically is a webserver and browser bundled in one program. – Franz Gleichmann Oct 14 '15 at 11:03
0

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.

Ram Guiao
  • 352
  • 1
  • 7
  • 13