Printing Brother labels with PHP

I've created a PHP library which allows me to print Brother labels without having to install the Brother P-Touch application. The library could be used to automate the printing of shipping labels as part of a webshop workflow.

Sample usage

use Talal\LabelPrinter\Printer;  
use Talal\LabelPrinter\Mode\Escp;  
use Talal\LabelPrinter\Command;

$stream = stream_socket_client('tcp://192.168.1.8:9100', $errorNumber, $errorString);

$printer = new Printer(new Escp($stream));
$font = new Command\Font('brussels', Command\Font::TYPE_OUTLINE);

$printer->addCommand(new Command\CharStyle(Command\CharStyle::NORMAL));
$printer->addCommand($font);
$printer->addCommand(new Command\CharSize(46, $font));
$printer->addCommand(new Command\Align(Command\Align::CENTER));
$printer->addCommand(new Command\Text('Hello'));
$printer->addCommand(new Command\Cut(Command\Cut::FULL));
$printer->printLabel();

flcose($stream);  

You can find the library at https://github.com/RamyTalal/Label-Printer.

Ramy Talal

Read more posts by this author.