We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

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 www.stackoverflow.com.

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);

    // https://windowsitpro.com/systems-management/how-can-i-print-usb-printer-command-prompt
    exec('print /d:LPT2: ' . $file);

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