1. Go to this page and download the library: Download coyotito/ipp library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coyotito / ipp example snippets
use Coyotito\Ipp\Printer;
$printer = Printer::connect('ipps://192.168.1.50:631/ipp/print');
// What can it do? (Get-Printer-Attributes → typed view)
$caps = $printer->capabilities();
$caps->makeAndModel(); // "Office Printer"
$caps->isOnline(); // true
$caps->hasMediaReady('na_legal_8.5x14in');
$caps->supportsColor();
$caps->supportsDuplex();
// Print, fluently. Nothing is sent until ->send().
$job = $printer->print($bytes, 'image/jpeg')
->copies(2)
->color()
->media('na_letter_8.5x11in')
->duplex()
->pages('1-5')
->send();
$job->id; // 14
$job->status(); // JobState::Processing → Completed (re-fetched live)
$job->isCompleted();
$job->cancel();
use Coyotito\Ipp\Discovery\Discovery;
foreach (Discovery::mdns()->discover(timeout: 5) as $printer) {
echo $printer->uri; // ipp://office-printer.local:631/ipp/print
echo $printer->name; // "Office Printer"
}
// Always-available fallback: register by IP/host.
$printer = Discovery::mdns()->manual('192.168.1.50', secure: true);
use Coyotito\Ipp\Transport\GuzzleTransport;
$printer = Printer::connect($uri, new GuzzleTransport(
client: $myPsr18Client, // optional; defaults to a configured Guzzle client
username: 'admin', // optional Basic auth
password: 'secret',
verifyTls: false, // printers ship self-signed certs (default)
));
$caps = $printer->capabilities();
$format = $caps->preferredFormat([
'application/pdf', // send as-is if supported
'image/pwg-raster', // else rasterize to PWG Raster (IPP Everywhere)
'image/urf', // or Apple Raster (AirPrint)
'image/jpeg', // last resort
]);
$caps->pwgRasterResolutions(); // resolutions valid for raster output
$caps->printQualitiesSupported();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.