A library to aid using the ipp protocol in php, for example to send print jobs to print servers that support the protocol
composer require digitalrevolution/ipp
$server = new IppServer();
$server->setUri('https://cups.local');
$server->setUsername('admin'); // optional
$server->setPassword('admin'); // optional
$ipp = new Ipp($server, new Psr18Client());
// define a printer
$printer = new IppPrinter();
$printer->setHostname('my.printer');
// print a file on the selected printer
$ippFile = new IppPrintFile(file_get_contents('/dir/file.ps'), FileTypeEnum::PS);
$ipp->print($printer, $ippFile);
$printJob = $ipp->print($printer, $ippFile);
$updatedPrintJob = $ipp->getJobAttributes($printJob->getJobUri());
$printer = new IppPrinter();
$printer->setHostname('my.printer');
$printer->setDeviceUri('my.uri');
$printer->setLocation('location');
$ipp->printerAdministration()->createPrinter($printer);
$printer = new IppPrinter();
$printer->setHostname('my.printer');
$ipp->printerAdministration()->deletePrinter($printer);
$printer = new IppPrinter();
$printer->setHostname('my.printer');
$response = $ipp->getPrinterAttributes($printer);
$attributes = $response->getAttributes();
$printerName = $attributes["printer-name"]->getValue();
This project is created to be easily extensible, adding a new IPP operation is as simple as making sure it has an identifier in IppOperationEnum
Then adding any Job, Printer or Operation Attributes as required by your standard.
Finally sending the request and parsing the response using the standard parser.
class MyOperation
{
public function __construct(private readonly IppHttpClientInterface $client)
{
}
public function myOperation(): IppResponseInterface
$operation = new IppOperation(IppOperationEnum::OperationType);
$operation->addOperationAttribute(new IppAttribute(IppTypeEnum::Charset, 'attributes-charset', 'utf-8'));
// set your attributes
return $this->client->sendRequest($operation);
}
}
See contributing.md
Pull requests welcome for adding standard IPP Operations
At 123inkt (Part of Digital Revolution B.V.), every day more than 50 development professionals are working on improving our internal ERP and our several shops. Do you want to join us? We are looking for developers.