Skip to content

Commit

Permalink
Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
kduma committed Apr 17, 2019
1 parent dd3107e commit 6ff261c
Showing 1 changed file with 65 additions and 9 deletions.
74 changes: 65 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,73 @@
php-lpd
=======
# PHP-LPD

PHP LPD (virtual printer in PHP)
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Total Downloads][ico-downloads]][link-downloads]

* Run `example\server.php` (CLI should be better), the server listens on 127.0.0.1:515 (change that if needed).
LPD Server and Client for PHP language.

You should be good to go, you can either:
## Install

* Run `example\client.php` (which works with a lovely class by Mick Sear), change the IP:PORT if needed.
Via Composer

or
```bash
$ composer require kduma/lpd
```

* Install a generic LPR text printer and start printing (if you are printing non-latin characters, please configure your printer with the correct font).
## Usage

Data sent to the printer is echoed, and then written to a `example\dump.txt` text file, you can change that in `example\server.php`.
### Server
``` php
(new KDuma\LPD\Server\Server())
->setAddress($address)
->setPort($port)
->setMaxConnections($max_connections)
->setHandler(function ($incoming_data, $ctrl) {
echo $incoming_data; // Do something with it!
})
->run();
```

### Client

#### Text print job

For printing clear text use `TextJob` class:
``` php
$job = new KDuma\LPD\Client\Jobs\TextJob("This is content!");
$job->appdendContent("\n");
$job->appdendContent("And this is second line.");
```

#### File print job

For printing files, text or binary, use `FileJob` class:
``` php
$job = new KDuma\LPD\Client\Jobs\FileJob("my_raw_file.txt");
```

#### Print Service

For printing files, text or binary, use `FileJob` class:
``` php
$configuration = new KDuma\LPD\Client\Configuration($address, $queue_name, $port, $timeout);

$print_service = new KDuma\LPD\Client\PrintService($configuration);

$print_service->sendJob($job);
```

# Original Attribution

This package is based on classes created by [Ivan Bozhanov](https://github.com/vakata)
([server](https://github.com/vakata/php-lpd/blob/master/class.lpd.php), 2013)
and Mick Sear
([client](https://github.com/vakata/php-lpd/blob/master/example/class.lpr.php), 2005).




[ico-version]: https://img.shields.io/packagist/v/kduma/lpd.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/kduma/lpd.svg?style=flat-square

[link-packagist]: https://packagist.org/packages/kduma/lpd
[link-downloads]: https://packagist.org/packages/kduma/lpd

0 comments on commit 6ff261c

Please sign in to comment.