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.
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.
This API was developed with the Lumen PHP framework. Check its requirements to setup your local server.
- Clone this repository or download the latest release and place it in your local server.
- Execute composer install.
- Setup your environment configuration.
- Set your printers.json file. You can use the printers.example.json as an example source.
- Set the CLIENT_API_TOKEN in your environment configuration.
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();
This application is open-sourced software licensed under the MIT license