Download the PHP package rafaelcecchin/cups-printer without Composer
On this page you can find all versions of the php package rafaelcecchin/cups-printer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cups-printer
cups-printer π¨οΈ
After spending a lot of time searching for a simple solution to print files directly from PHP, I decided to create my own Composer library. π
Initially, I thought it would be easier to find a solution that fits different environments, but I was mistaken. Many of the existing solutions for printing with CUPS + PHP are outdated, involve a lot of code, and overlook the fact that many developers use Windows for development and Linux for production environments. π₯οΈβ‘οΈπ§
This project utilizes the CUPS command:
"Okay, but what about the cases you mentioned, where I work with a Windows development environment and a Linux production environment?" π
It will work too, and the solution is simpler than you might think. I'll explain more about this below. π
How to Use
Hereβs a code snippet demonstrating the functions of the library. π
The only requirement is that the host must have cups-client installed. π οΈ
On Linux, you can run:
On Windows, one solution is to download Linux from the Windows Store. Yes, this is now possible through WSL technology. Just access the Windows Store, search for the Linux distribution you want, and install cups-client
inside it.
In your project, you should create a class that extends CupsPrinter
and, using polymorphism principles, override the cmdPrintCommand
function. Hereβs an example of how I did it. π§©
In this case, I downloaded Ubuntu from the Windows Store. To run a command inside it, I prepend ubuntu run
before the lp
command and also adjust the file path to the Unix format, adding /mnt/
before the drive letter.
Simple, right? π
I hope this solution makes sense to you! π