Skip to content

Files

Latest commit

 

History

History
40 lines (24 loc) · 1.75 KB

readme.md

File metadata and controls

40 lines (24 loc) · 1.75 KB

ESC/POS Print Server API

This application exposes an API to allow print on local thermal receipt printers from the WAN. This project uses and exists thanks to the awesome mike42/escpos-php PHP package.

The problem

If you want to print from your application to a thermal printer and it is on a different network you will probably need to stand up a VPN service. But if you are not able to do this, with this application installed in your local network the problem is solved.

Installation

This API was developed with the Lumen PHP framework. Check its requirements to setup your local server.

  1. Clone this repository or download the latest release and place it in your local server.
  2. Execute composer install.

Configuration

  1. Setup your environment configuration.
  2. Set your printers.json file. You can use the printers.example.json as an example source.
  3. Set the CLIENT_API_TOKEN in your environment configuration.

Usage

The easiest way print via this API is using this connector implementation. With it, you only need to change the connector in your implementation with the mike42/escpos-php PHP package:

<?php 

$connector = new PrintServerApi('https://myapihost', 'printerId', 'MySecretToken');

$printer = new Printer($connector);

$printer->text("Hello World!\n");
$printer->cut();
$printer->close();

License

This application is open-sourced software licensed under the MIT license