ORIGINAL FROM: https://github.com/mike42/escpos-php/tree/master
STEP:
- Download all files in this github or the source
- Put the folder of all Mike42 to third_party
- Create File in libraries folder, with EscPos.php
- And run!
Example:
try {
// Enter the device file for your USB printer here
// You can check the tutorial here: https://mike42.me/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux
$connector = new FilePrintConnector("/dev/usb/lp0");
/* Print a "Hello world" receipt" */
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
/* Close printer */
$printer -> close();
} catch (Exception $e) {
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
More: https://mike42.me/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux
Notes:
- Login as Root
- Write: chown -R user:user /dev/usb
- As alternatif if, sudo usermod -a -G lp user NOT WORKING!
This Is in Codeigniter!
$this->load->library("EscPos.php");
try {
// Enter the device file for your USB printer here
$connector = new Escpos\PrintConnectors\FilePrintConnector("/dev/usb/lp0");
/* Print a "Hello world" receipt" */
$printer = new Escpos\Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
/* Close printer */
$printer -> close();
} catch (Exception $e) {
echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
Done!
More info: topidesta.wordpress.com