Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

print a ticket

i need to directly send to the printer a ticket

can someone help me please

This isn't a Phalcon specific question. You will have better luck asking on a more general purpose forum like

In my personal experience though, sending a print job to a printer from PHP is pretty much impossible.


You can generate PDF or PostScript file and send it to printer (print-server). Usualy PDF file will generate and download to user on the site.


this is actually pretty easy with message queing instead of using cron/scheduling

 * Receive a print request and print.
$context = new ZMQContext();
$sub = $context->getSocket(ZMQ::SOCKET_SUB);
$sub->setSockOpt(ZMQ::SOCKOPT_SUBSCRIBE, '');

while (true) {
    $printJob = $sub->recv();

    $html = file_get_contents($printJob);
    $file = get_temp_dir() . '/printJob_' . sha1($html) . '.html';
    file_put_contents($file, $html);

    exec('print /d:LPT2: ' . $file);

whether or not its a good idea is something a lot of people have discussed