temant/printer

A simple PHP library for interacting with network printers.

dev-main 2025-02-24 11:05 UTC

This package is not auto-updated.

Last update: 2025-04-22 10:06:55 UTC


README

A simple PHP library for interacting with network printers. It allows sending data to printers over the network via the RAW printing protocol.

Installation

  1. Clone the repository:

    git clone https://github.com/slvstar/temant-printer.git
  2. Install dependencies using Composer:

    composer install

Usage

Printer Class

To create a printer instance and print data:

use Temant\Printer\Printer;

$printer = new Printer('192.168.1.100', 9100);  // Use the correct IP and port of your printer
$printer->print("Hello Printer!");

echo $printer->getPrinterStatus();  // Output: 'Online' if connected

Exception Handling

The library throws the following exceptions:

  • PrinterException: For issues with the printer connection or printing.
  • ConnectionException: For connection failures.

Running Tests

To run tests, you need PHPUnit installed:

composer require --dev phpunit/phpunit

Run the tests:

./vendor/bin/phpunit tests

PHPStan Analysis

To ensure the code follows best practices and type safety, use PHPStan for static analysis:

composer require --dev phpstan/phpstan
./vendor/bin/phpstan analyse

License

MIT License. See LICENSE file for details.