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?
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
get a receipt printer that shows up as a regular printer and just
styling your receipts accordingly
write a Thick Client instead or
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.
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.
Related
So, long story short, I have a site running in my home off a Raspberry Pi (Raspbian) (secured and not shared with anyone other than me, local within the network) running a down-and-dirty file upload system. I want to configure the server to automatically send any file I send to it to the printer, and print out automatically. I have CUPS installed on the pi, but I have no idea what else to do.
the printer is a wifi printer (Xerox colorcube) if that matters
I was thinking possibly a python script?
Ok so I completed the task, and I am sharing this so any voyagers who stumble across this page don't find it unanswered.
Get the solution at the github repo
So here is what I wanted to do. I have an Apache2 server up and running on my raspberry pi 3, which is currently serving as a webradio using php commands and mpd/mpc. The raspberry is also connected via HDMI to a display.
I now like to have another page on the webserver which let's me start different roms in an emulator and display the output signal on the display connected to the remote server and and also lets me use a controller connected also to the remote server.
This is what I have done so far.
I have successfully installed Retroarch which is up and running.
I used exec("export DISPLAY=:0.0; retroarch -c /home/pi/path/to/config -L /home/pi/path/to/libretro/core /home/pi/path/to/rom") to start the emulator on the remote sever.
The problem is as follows. Even though I started the emulation successfully on the screen I cannot use the input devices connected to the remote server. How can I make the input devices of the server accessible with a php-command or something else? Can somebody point me to a solution to achieve this? Also the exec-command does not seem to accept my arguments besides the config file argument. I guess it has to do with user rights. But I am really stuck at this point.
Thanks for any replies.
Disclaimer: This is my first post. So I am sorry for bad terminology.
I have an application written in VB.net that runs on a clients pc.
I also have a website written in mostly javascript, http and php.
The thing I want to do is to connect the website to the application, so that when i.e. a certain button is pressed, it connects to the client application and raises an event.
I have tried approaches like TCP socket communication by having a TCP Socket Server running in the background of the client application. I can connect to the server by having a client connection from another vb.net application, but whenever I try to connect through PHP it fails. (I have only tried PHP since server-side scripting seems to make more sense in this case)
Another approach I have tried is to have an HTTP server running in the background of my desktop application and then have a PHP script connect to it, that fails as well.
One thing that I've been thinking about as a last resort is to simply have a textfile on the webserver and a PHP script writing to it after given parameters and then have the client application to read the file every few seconds. But this wouldn't be very efficient with larger amounts of data, would it?
What is the proper way of doing this?
If you have any questions about the code I've been using, feel free to ask.
If you don't get my blurry explanation, try this image: http://i.imgur.com/8njxVFj.png
Thanks in advance.
To have your data more organized i would suggest you to store your data on a database server for example mysql (which is free).
I am working on my senior project at university and I have a question. My advisor and other workers don't know much more on the matter so I thought I would toss it out to SO and see if you could help.
We want to make a website that will be hosted on a server that we are configuring. That website will have buttons on it, and when visitors of that website click a certain button we want to register an event on the server. We plan on doing this with PHP.
Once that event is registered (this is where we get lost), we want to communicate with a serial device on a remote computer. We are confident we can set up the PHP event/listener for the button press, but once we have that registered, how do we signal to the remote computer(connected via T1 line/routers) to communicate with the serial device? What is this sequence of events referred to as? The hardest thing for us (when researching it) is that we are not certain what to search for!
We have a feeling that a python script could be running on the server, get signals from the PHP listener, and then communicate with the remote PC. The remote PC could also be running a python script that then will communicate with our serial device. Again, most of this makes sense, but we are not clear on how we communicate between Python and PHP on the web server (or if this is possible).
If any one could give me some advice on what to search for, or similar projects I would really appreciate it. Thanks,
Both php and python can communicate via sockets, so I guess that is a good bet.
In PHP, when you receive the signal from the click button, open a socket to your python app with socket_create.
In python, you would need to implement a server socket (SocketServer) that listens for a connection.
Try reading up on sockets communication in general and socket programming in php and python specifically.
You can set up a web server also on the remote computer, perhaps using the same software as on the public server, so you do not need to learn another technology. The public server can make HTTP requests and the remote server responds by communicating with the serial device.
I've got a Epson Thermal printer, model TM-T20 which I'm setting up for clients.
Our webserver is a linux server, and the client machines will be Windows machines.
Is it possible with php, to directly control the thermal printer attached to the clients computer?
I have looked at javascripts window.print(), but that is not what I want, if possible I want to bypass the print dialog.
Thanks,
Tony
No. PHP has absolutely nothing to do at all with the client's printer. If the printer was attached to the machine the PHP script is running on (i.e. the server), there may be something you could do. As it is, PHP only sends text to the client. From there, the client's browser and printer software has to handle it.
Alternatively, if the Windows box ran a print server exposing the printer that PHP could talk to over the network, you could talk to the printer directly. But that wouldn't be a normal PHP server/client relationship anymore.
printing from php isn't that easy, most web apps i have seen generate a pdf and and the clients print that.
have a look at http://www.vendhq.com/ they do a point of sale app for shops, and have something you need to download and install to print till dockets via a receipt printer. it might give you some inspiration
I have done exactly this before. It was quite tricky, using a ubuntu server on the workplace's LAN and a thermal printer on another ubuntu computer in the shipping area. That computer was running a php service listening to a port and was headless, hiding inside the cabinetry.
The business's internal web php "application" on the LAN server would coordinate with their e-commerce and UPS.com to print a shipping label. I forgot how UPS sent it but we used imagemagik to tweak the final image to the perfect pixel width. Then the LAN server would connect to the target's php socket server and it would send the proper commands to the serial port that the printer was connected to, along with the image data.
To call that solution madhatterey is an understatement... but was quite amazing to have labels appear magically upon "shipping" an order. No print dialog or anything. Cheapest solution is get an Atom box that can run Ubuntu and get a printer with a ppd file that works. Then just queue it up properly. Same concept as remote printing in linux.
You could possibly do the print request from a webpage's AJAX request and not need the extra infrastructure (or target computer's php socket server).