PHP code example of grupocoqueiro / escpos-php

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


$img = EscposImage::load("logo.png");
$printer -> graphics($img);
bash
composer 
bash
git clone https://github.com/grupocoqueiro/escpos-php vendor/grupocoqueiro/escpos-php
bash
php hello-world.php > /dev/usb/lp0
bash
php hello-world.php > foo.txt
lpr -o raw -H localhost -P printer foo.txt

php hello-world.php > foo.txt
net use LPT1 \\server\printer
copy foo.txt LPT1
del foo.txt