- How do I install and configure rawilk/laravel-printing?
- Install it with Composer using composer require rawilk/laravel-printing, then publish the package config file with the vendor:publish command. Set your driver and default printer name through the config file or environment variables. Laravel auto-discovers the service provider, so no manual registration is needed. From there you can resolve the print manager or use the facade to list printers and dispatch jobs.
- Which Laravel and PHP versions does laravel-printing support?
- The package targets modern Laravel releases on PHP 8.x and is installed through Composer with a publishable config file. It follows standard Laravel package conventions, including a service provider, a facade, and a driver-based manager. Because exact version constraints change between releases, always check the composer.json requirements on Packagist against your application's Laravel and PHP versions before upgrading.
- Can I print a PDF directly to a printer from Laravel?
- Yes. The typical flow is to generate or receive the document as a PDF, then hand the file path to the print manager and let the configured driver dispatch it. The package does not create PDFs itself, so pair it with your preferred PDF or view-rendering library. Keep in mind that media size, trays, duplex, and copies are not uniformly supported across drivers, so verify output on your actual printer models.
- How do I list available printers with this package?
- The print manager exposes a unified API for listing printers that the configured driver can see. Under CUPS this comes from the host's configured print queues, so the application host must be able to reach the CUPS server and query it. If a printer is missing from the list, check that it is configured on the print host and that the web user has permission to query it.
- Does laravel-printing work in Docker, Kubernetes, serverless, or Heroku?
- Not out of the box. The package shells out to OS-level print binaries such as lp and lpr under CUPS or PowerShell print cmdlets on Windows, and typical base images do not include CUPS client binaries. Ephemeral containers also lose spool state on restart. The practical solution is a dedicated print relay host that runs CUPS with your printers configured, which the application addresses as a stable network endpoint.
- How do I test printing in Laravel without a real printer?
- Use the bundled log driver in local and CI environments so the full application code path is exercised without hardware. That keeps your tests fast and deterministic, but it does not validate real output, so plan separate acceptance testing against a staging print relay. If you need stricter assertions, bind a fake implementation of the print manager contract in your test container.
- How do I write a custom print driver for laravel-printing?
- The package uses a driver-based manager behind a shared contract, so you can implement that contract for your own environment. Register your driver through the manager's extension point in a service provider, then select it in the config file like any built-in driver. This is useful when your infrastructure uses a print API, a relay service, or an operating system the cups, windows, and log drivers do not cover.
- Why is my print job failing with lp or lpr not found?
- That error almost always means the CUPS client binaries are missing from the host or container image, or are not on the PATH used by your PHP process. Install the CUPS client package on the application host, or better, point the app at a dedicated print relay server that has CUPS and the printers configured. Also confirm the user running PHP has OS-level permission to invoke the print client and reach the spooler.
- How do I print to a Windows printer from Laravel?
- The package includes a Windows driver that invokes PowerShell print cmdlets on the host machine. That means the Laravel application, or whatever host it delegates to, must be running Windows with the target printer installed and the web user permitted to print. For mixed estates, the common pattern is a Linux application tier plus a small Windows relay dedicated to the printers that require it.
- How should I handle print job status, retries, and queueing?
- Dispatch print jobs from a queued job rather than inside a synchronous HTTP request, so slow spoolers do not block responses. Be aware that printing is fire-and-forget from the application's perspective: spooled is not printed, and job status reads are only as good as the underlying spooler. For regulated or fulfillment documents, add your own audit trail, retry policy, and operator notification rather than relying on the driver alone.