PHPackages                             laulaman/receipt-printer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. laulaman/receipt-printer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laulaman/receipt-printer
========================

A library to print receipts

v1.0(3mo ago)05MITPHPPHP ^8.2CI failing

Since Jan 29Pushed 3mo agoCompare

[ Source](https://github.com/LauLaman/receipt-printer)[ Packagist](https://packagist.org/packages/laulaman/receipt-printer)[ RSS](/packages/laulaman-receipt-printer/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Receipt Printer
===============

[](#receipt-printer)

`laulaman/receipt-printer` is a PHP library for building and printing receipts on POS receipt printers. It will send raw printer instruction bytes to the printer.

### Features

[](#features)

- **Supports multiple printers and models** ([tested printers](./docs/tested-printers.md))
- **Builder-style API** with chaining ([api-reference](./docs/api-reference.md))
- **Text formatting**: bold, invert, alignment, text size, font type
- **Columns** for items and prices
- **Separator lines**, feed, and cut
- **Logos** (printer-stored)
- **QR codes** and barcodes (EAN13, CODE128, etc.)
- **Socket-based printing**

---

Installation
------------

[](#installation)

```
composer require laulaman/receipt-printer

```

> Minimum PHP 8.2

---

Usage
-----

[](#usage)

### 1. Create the factory

[](#1-create-the-factory)

```
use LauLaman\ReceiptPrinter\Application\PrinterFactory;use LauLaman\ReceiptPrinter\StarMicronics\Driver\Transformer\StarMicronicsPrinterDriver;use LauLaman\ReceiptPrinter\Infrastructure\Normalizer\StarMicronics\StarMicronicsPrinterTextNormalizer;

$printerFactory = PrinterFactory::create();

// Or construct it yourself:
$printerFactory = new PrinterFactory(
    new StarMicronicsPrinterDriver(
        new StarMicronicsPrinterTextNormalizer(),
        new SettingsTransformer(),
        new LayoutTransformer(),
        new PaperTransformer(),
        new BarcodeTransformer(),
        new GraphicsTransformer(),
        new SoundTransformer(),
    )
);
```

### 2. Connect to a Printer

[](#2-connect-to-a-printer)

Choose your transport type, select your printer and Paper size to get a Printer object from the factory

The following transport layers are bundled:

- BluetoothTransport
- CupsTransport
- IppTransport
- SocketTransport
- UsbTransport

You can also create your own transport layer by implementing `LauLaman\ReceiptPrinter\Domain\Transport\PrinterTransport`

> At this moment only the SocketTransport is actually tested since that is what I have.
>
> If you are able to confirm that other transports work, please let me know through a GitHub issue

```
use LauLaman\ReceiptPrinter\Domain\Enum\PrinterModel;
use LauLaman\ReceiptPrinter\Domain\Enum\PaperWidth;

// Using a socket
$printer = $printerFactory->socket(
    PrinterModel::STAR_MC_PRINT2,
    PaperWidth::SMALL,
    '192.168.0.12', // Printer IP
);

// Using USB
$printer = $printerFactory->usb(
    PrinterModel::STAR_MC_PRINT2,
    PaperWidth::SMALL,
    '/dev/usb/lp1',
);
```

---

### 3. Start printing!

[](#3-start-printing)

Now you can start sending commands to the printer, but I recommend using the RecieptBuilder (see 4. Use the builder)

Simple Hello world example

```
use LauLaman\ReceiptPrinter\Domain\Command\Action\Cut;use LauLaman\ReceiptPrinter\Domain\Command\Draw\Text;

$printer->send(
    [], //-- Printer settings more on this later
    new Text('Hello World!'),
    new Cut(partial: true),
);
```

Let's make a receipt for a coupon for a guest Wi-Fi

```
use LauLaman\ReceiptPrinter\Domain\Command\Action\Cut;use LauLaman\ReceiptPrinter\Domain\Command\Draw\QRCode;use LauLaman\ReceiptPrinter\Domain\Command\Draw\Separator;use LauLaman\ReceiptPrinter\Domain\Command\Draw\Text;use LauLaman\ReceiptPrinter\Domain\Command\Layout\Align;use LauLaman\ReceiptPrinter\Domain\Command\Style\Bold;use LauLaman\ReceiptPrinter\Domain\Command\Style\Font;use LauLaman\ReceiptPrinter\Domain\Command\Style\Magnify;use LauLaman\ReceiptPrinter\Domain\Command\Style\Negative;use LauLaman\ReceiptPrinter\Domain\Command\Style\Underline;use LauLaman\ReceiptPrinter\Domain\Enum\Alignment;use LauLaman\ReceiptPrinter\Domain\Enum\FontType;use LauLaman\ReceiptPrinter\Domain\Enum\QRCodeErrorCorrection;use LauLaman\ReceiptPrinter\Domain\Receipt;

$date = (new \DateTime("+24 hours"))->format('Y-m-d H:i:s');

$receipt = new Receipt(
    [], // settings
    [
        new Align(
            Alignment::CENTER,
            new Bold(new Magnify(3, text: new Text("Wi-Fi"))), new NewLine(),
            new Magnify(2, text: new Text("YourWifi")), new NewLine(),
            new Separator(),
            new Magnify(2, text: new Negative(new Text("12345-67890"))), new NewLine(),
            new Font(FontType::B, new Underline(new Text("Valid until {$date}"))), new NewLine(),
            new Separator("."),
            new QRCode("WIFI:T:nopass;S:SSID;;", 8, QRCodeErrorCorrection::MEDIUM)
        ),
        new Cut(partial: true)
    ]
);

//-- Sent the receipt to the printer
$printer->print($receipt);
```

### 4. Use the builder

[](#4-use-the-builder)

Let's make a receipt for a coupon for a guest Wi-Fi using the ReceiptBuilder

```
use LauLaman\ReceiptPrinter\Domain\Enum\Alignment;use LauLaman\ReceiptPrinter\Domain\Enum\FontType;use LauLaman\ReceiptPrinter\Domain\ReceiptBuilder;

$date = (new \DateTime("+24 hours"))->format('Y-m-d H:i:s');

$builder = ReceiptBuilder::create()
    ->align(Alignment::CENTER) //-- Enter align mode (center)
        ->bold() //-- Enter bold mode
            ->magnify(3) //-- Enter magnification mode
                ->text("WiFi") //-- Print text
            ->end() //-- Exit magnification mode
        ->end() //-- Exit bold mode
        ->newline() //-- Start a new line
        ->magnify(2, text: "YourWifi") //-- Print text in magnification mode
        ->newline() //-- Start a new line
        ->separator() //-- Print separator
        ->magnify(2) //-- Enter magnification mode
            ->negative("12345-67890") //-- Print text in invert mode
        ->end() //-- Exit magnification mode
        ->newline() //-- Start a new line
        ->font(FontType::B) //-- Enter specific Font mode
            ->text("Valid until {$date}") //-- Print text
        ->end() //-- Exit specific Font mode
        ->newline() //-- Start a new line
        ->separator('#') //-- Print a separator and use # as char
        ->qrCode('WIFI:T:nopass;S:SSID;;', 8) //-- Print QR code
    ->end() //-- Exit align mode (center)
    ->cut(partial: true); //- Cut the paper using a partial cut;

$receipt = $builder->build(); // Build the receipt

//-- Sent the receipt to the printer
$printer->print($receipt);
```

---

### 3. Print a Full Store Receipt

[](#3-print-a-full-store-receipt)

```
use LauLaman\ReceiptPrinter\Domain\Enum\Alignment;use LauLaman\ReceiptPrinter\Domain\Enum\BarcodeType;use LauLaman\ReceiptPrinter\Domain\ReceiptBuilder;use PrintSetting\CodePageSetting;

$builder = ReceiptBuilder::create(new CodePageSetting())
    ->align(Alignment::CENTER) //-- Enter align mode (center)
        ->logo(2) //-- Print logo stored on the memory on the printer itself
        ->bold() //-- Enter bold mode
            ->magnify(2, text: "MY STORE") //-- Print text with a 2 x magnification
        ->end() //-- Exit bold mode
        ->text("123 Main Street") //-- Print text
        ->text("City, State 12345") //-- Print text
        ->text("Tel: (555) 123-4567") //-- Print text
        ->feed() //-- Feed the paper by 1 line
        ->separator() //-- Print a seperator
        ->magnify(3, 4)//-- Enter magnification mode, magnify 3x in with and 4x in height
            ->negative("10897") //-- Print negative text (white on black)
        ->end()//-- Exit magnification mode
    ->end() //-- Exit align mode (center)
    ->separator() //-- Print separator
    ->column("1 x Cappuccino", "€4.50") //-- Print a column with text on the left and the price on the right
    ->column("1 x Pizza", "€13.50")
    ->column("    2 x Deposit",  fn($right) => $right->negative("€0.30"))//- Print a column with the right text negative
    ->separator() //-- Print separator
    ->bold() //-- Enter bold mode
        ->column("TOTAL", "€43.30") //-- Print a column but now bold since we're in bold mode
    ->end() //-- Exit bold mode
    ->feed()//-- Feed the paper by 1 line
    ->align(Alignment::CENTER)//-- Enter align mode (center)
        ->text("Thank you for your purchase!") //-- Print text
        ->feed(2)//-- Feed the paper by 2 lines
        ->barcode("123456", BarcodeType::CODE128) //-- Print a code 128 barcode
    ->end()//-- Exit align mode (center)
    ->cut();//-- Cut paper

$receipt = $builder->build(); // Build the receipt

//-- Sent the receipt to the printer
$printer->print($receipt);
```

---

Contributing
------------

[](#contributing)

1. Fork the repository
2. Make your changes
3. Update the `composer.json` version if needed
4. Submit a pull request

###  Health Score

38

—

LowBetter than 84% of packages

Maintenance87

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

99d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/930ca3b1756d00a63c8ff3363e81f16f961cf3ef79ff0c9d362670c36d97e456?d=identicon)[LauLaman](/maintainers/LauLaman)

---

Top Contributors

[![LauLaman](https://avatars.githubusercontent.com/u/8283992?v=4)](https://github.com/LauLaman "LauLaman (8 commits)")

---

Tags

printerposreceiptpoint-of-saleticketthermalmC-Print2mC-Print3

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laulaman-receipt-printer/health.svg)

```
[![Health](https://phpackages.com/badges/laulaman-receipt-printer/health.svg)](https://phpackages.com/packages/laulaman-receipt-printer)
```

###  Alternatives

[mike42/escpos-php

PHP receipt printer library for use with ESC/POS-compatible thermal and impact printers

2.7k1.9M22](/packages/mike42-escpos-php)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[ramytalal/label-printer

An implementation of the Brother label printer API.

6641.8k](/packages/ramytalal-label-printer)[nfephp-org/posprint

Thermal POS printer library

7131.7k2](/packages/nfephp-org-posprint)[patrickschur/stanford-nlp-tagger

PHP wrapper for the Stanford Natural Language Processing library. Supports POSTagger and CRFClassifier.

7426.7k1](/packages/patrickschur-stanford-nlp-tagger)[hackzilla/ticket-bundle

This Bundle provides multilingual ticketing functionality for Symfony applications.

6529.3k1](/packages/hackzilla-ticket-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
