Download the PHP package blutrixx/nativephp-escpos-printer without Composer
On this page you can find all versions of the php package blutrixx/nativephp-escpos-printer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download blutrixx/nativephp-escpos-printer
More information about blutrixx/nativephp-escpos-printer
Files in blutrixx/nativephp-escpos-printer
Package nativephp-escpos-printer
Short Description NativePHP Mobile plugin for Bluetooth ESC/POS thermal receipt printers
License proprietary
Informations about the package nativephp-escpos-printer
Blutrixx ESC/POS Printer
A NativePHP Mobile plugin for talking to Bluetooth ESC/POS thermal receipt printers — connect, print formatted text with an optional logo, and get notified of connection/print state via native events.
Composer package: blutrixx/nativephp-escpos-printer
Repo: joelnjoshkibona/nativephp-escpos-printer
Current release: v1.0.0
Requirements
- PHP ^8.2
- A Laravel app running under
nativephp/mobile^3.3 (enforced bycomposer.json; 4.x is not supported yet) - Android: pulls in
com.github.DantSu:ESCPOS-ThermalPrinter-Android:3.3.0via JitPack (repository auto-registered by this plugin's manifest) and requests the Bluetooth permissions (see Android manifest below). - iOS: declares
NSBluetoothAlwaysUsageDescription/NSBluetoothPeripheralUsageDescriptionand thebluetooth-centralbackground mode.
Installation
Not on Packagist yet.
As a git submodule (how this repo itself consumes it):
Without a submodule:
Laravel auto-discovers EscPosPrinterServiceProvider.
How the bridge works
Unlike blutrixx/nativephp-device-utils, every method on this package's facade is synchronous — connect, print, and status checks all block and return a real result, no native-event listening required. Internally each call goes through nativephp_call() with JSON-encoded params and a JSON-decoded response.
Three native events still exist for cases where you want to react to connection state changing outside a direct method call (e.g. the printer disconnecting mid-session) — listen for these the same way described in blutrixx/nativephp-device-utils' README if you need them.
Logo printing — you must configure your own logo
print() and testPrint() support a {{LOGO}} or {{LOGO:filename.png}} placeholder inside the ESC/POS command string, which gets swapped for the actual printed bitmap. This package ships no default logo asset — that's deliberate. It used to (an earlier, single-app version of this plugin hardcoded one brand's logo as the default), but a shared plugin can't sensibly default to any one app's branding, so:
- Publish the config:
php artisan vendor:publish --tag=escpos-printer-config - Bundle your own logo image into your app's own native build assets (this package doesn't manage that for you — it only resolves a filename at print time; getting that file onto the device is your app's asset pipeline).
- Point
config/escpos-printer.php'sdefault_logo(or theESCPOS_PRINTER_DEFAULT_LOGOenv var) at that filename, or always pass it explicitly:
If neither an explicit filename nor a configured default is available, the {{LOGO}} line is silently dropped from the print job — the receipt still prints, just without a logo, rather than falling back to any particular app's image.
API reference
| Method | Returns | Notes |
|---|---|---|
checkPermissions() |
array |
Bluetooth permission status |
requestPermissions() |
array |
Prompts for the Bluetooth permission |
connect() |
array |
Connects to the first bonded Bluetooth printer found |
disconnect() |
array |
|
isConnected() |
bool |
|
getPrinters() |
array |
List of bonded Bluetooth devices |
ensureConnected() |
array |
Connects only if not already connected — safe to call before every print |
print(string $commands) |
array |
Connects first if needed, resolves any {{LOGO}} placeholder, strips empty <img></img> tags, then prints |
testPrint() |
array |
Prints a test receipt |
processLogoInCommands(string $commands) |
string |
Resolves a {{LOGO}}/{{LOGO:file.png}} placeholder to hex; called automatically by print() |
convertLogo(string $filename) |
array |
Converts an image (from your app's bundled assets) to an ESC/POS hex string — {hex: string} on success |
Events
All under Blutrixx\EscPosPrinter\Events\*: PrinterConnected, PrinterDisconnected, PrintCompleted, PrintFailed.
Android manifest
The plugin only talks to already-bonded printers (no discovery), so BLUETOOTH_SCAN and the location permissions are not declared. The Bluetooth hardware feature is declared required: false, so the app still installs on devices without Bluetooth; printing simply fails there.