Installation
1. The application
composer require darvis/printserver
php artisan migrate
The migration creates the print_jobs table. There is nothing to publish; publish the config only when you want to read the comments next to the settings:
php artisan vendor:publish --tag=printserver-config
2. A token for the box
php artisan print:token amsterdam
The command creates a token of 64 characters, writes it into PRINTSERVER_TOKENS in the .env and shows the token to put on the box. A box that already had a token gets a new one, and the old one stops working. When the config is cached, the command runs config:clear itself.
PRINTSERVER_ADMINISTRATION=amsterdam
PRINTSERVER_TOKENS="amsterdam:amsterdam:3f9a..."
With more than one location, run the command once per box; every box gets its own entry in the same variable. See Security for why the administration in the middle matters.
php artisan print:token --show # which boxes have a token, without the tokens
php artisan print:token amsterdam --print # only show the entry, leave the .env alone
3. Clean up old jobs
Without this the disk keeps every document that was ever printed. In routes/console.php:
use Illuminate\Support\Facades\Schedule;
Schedule::command('print:cleanup')->daily();
4. The box on location
The box is a mini pc or a Raspberry Pi with Linux, CUPS and the agent. The box on location describes the whole setup: the queues in CUPS, the configuration file and the service. In short, the box needs:
- the url of your application and the prefix of the endpoints,
- its token,
- a queue in CUPS per printer, named exactly like the key you use when you queue a job.
Check that it works
Queue a test page and watch it come out:
php artisan print:test PRINTER01
The box picks it up within a few seconds. When nothing comes out, check in this order:
php artisan tinker→Darvis\Printserver\Models\PrintJob::latest()->first()shows the status.pendingmeans the box never came by,claimedmeans it came by but did not report back,failedmeans CUPS refused the job and theerrorcolumn says why.- On the box,
journalctl -u printbox -n 50shows what the agent did. curl -s -X POST -H "Authorization: Bearer <token>" https://example.com/print/claimfrom the box itself proves whether the box can reach the application at all.
Troubleshooting covers the rest.