1. Go to this page and download the library: Download grupocoqueiro/escpos-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
grupocoqueiro / escpos-php example snippets
/* Call this file 'hello-world.php' */
ePrintConnector;
use grupocoqueiro\Escpos\Printer;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer->text("Hello World!\n");
$printer->cut();
$printer->close();
use grupocoqueiro\Escpos\PrintConnectors\NetworkPrintConnector;
use grupocoqueiro\Escpos\Printer;
$connector = new NetworkPrintConnector("10.x.x.x", 9100);
$printer = new Printer($connector);
try {
// ... Print stuff
} finally {
$printer -> close();
}
use grupocoqueiro\Escpos\PrintConnectors\FilePrintConnector;
use grupocoqueiro\Escpos\Printer;
$connector = new FilePrintConnector("/dev/ttyS0");
$printer = new Printer($connector);
use grupocoqueiro\Escpos\PrintConnectors\WindowsPrintConnector;
use grupocoqueiro\Escpos\CapabilityProfile;
$profile = CapabilityProfile::load("simple");
$connector = new WindowsPrintConnector("smb://computer/printer");
$printer = new Printer($connector, $profile);
use grupocoqueiro\Escpos\PrintConnectors\WindowsPrintConnector;
use grupocoqueiro\Escpos\CapabilityProfile;
$profile = CapabilityProfile::load("SP2000")
$connector = new WindowsPrintConnector("smb://computer/printer");
$printer = new Printer($connector, $profile);