Print GitHub Issue Receipts with a Raspberry Pi and PHP

This guide shows how to connect an Epson TM‑T88IV thermal receipt printer to a Raspberry Pi Zero W, install a PHP ESC/POS library, configure udev rules, set up a GitHub webhook via ngrok, and automatically print issue details as receipts.

21CTO
21CTO
21CTO
Print GitHub Issue Receipts with a Raspberry Pi and PHP

Hardware List

Required items:

Epson TM‑T88IV receipt printer

Raspberry Pi Zero W

Micro USB to USB adapter

USB‑B cable

The Epson printer uses the ESC/POS command set, which has libraries for many languages and is cheap on the second‑hand market.

Connecting the Printer

The Pi Zero W has a single micro‑USB port; connect it to the printer using the adapter and USB‑B cable.

Sending Data to the Printer

Use a PHP ESC/POS library (mike42/escpos‑php). Ensure the printer device is accessible, e.g., /dev/usb/lp0.

Run lsusb to obtain the vendor and product IDs, then create a udev rule:

SUBSYSTEM=="usb", ATTRS{idVendor}=="04b2", ATTRS{idProduct}=="0202", MODE="0664", GROUP="dialout"

Add your user to the dialout group:

sudo usermod -a -G dialout pi && sudo usermod -a -G dialout root

Restart udev: sudo service udev restart Install the library with Composer: composer require mike42/escpos-php Create index.php:

<?php
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;

$connector = new FilePrintConnector('/dev/usb/lp0');
$printer = new Printer($connector);

$printer->text('Hello, world!');
$printer->feed(2);
$printer->cut();

Run the script with root privileges: sudo php index.php If permission errors occur, adjust the device permissions:

sudo chmod +777 /dev/usb/lp0

Connecting to GitHub

Configure a GitHub webhook on the repository to trigger on new issues, sending a JSON payload to a public URL.

Expose the Pi’s local server using ngrok: ngrok http 8000 Start a PHP built‑in server on the Pi: sudo php -S 127.0.0.1:8000 Enter the ngrok URL in the GitHub webhook settings and save.

Final Code

Process only POST requests, decode the incoming JSON, and print the issue title and body:

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    return 'Error: Expecting POST request';
}

$data = json_decode(file_get_contents('php://input'), true);

$printer->setUnderline(true);
$printer->setEmphasis(true);
$printer->text($data['issue']['title']);
$printer->setEmphasis(false);
$printer->setUnderline(false);
$printer->text($data['issue']['body']);

Push a new issue to the repository; the printer will output a receipt with the issue details.

Summary

The setup can be extended to add QR codes linking back to the GitHub issue, include labels, severity, or adapt the concept for other webhook sources such as Jira, Bugsnag, or personal to‑do lists.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

AutomationPHPRaspberry PiESC/POSGitHub WebhooksReceipt Printer
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.