Skip to content

Commit 2c55537

Browse files
authored
Feature/cups (rawilk#2)
1 parent 35d26ee commit 2c55537

File tree

26 files changed

+984
-33
lines changed

26 files changed

+984
-33
lines changed

.github/workflows/php-cs-fixer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
steps:
1010
- name: Checkout code
11-
uses: actions/checkout@v1
11+
uses: actions/checkout@v2
1212

1313
- name: Fix style
1414
uses: docker://oskarstark/php-cs-fixer-ga

.github/workflows/psalm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
name: psalm
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v1
14+
- uses: actions/checkout@v2
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2

.github/workflows/run-tests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@ jobs:
1616
matrix:
1717
os: [ubuntu-latest, windows-latest]
1818
php: [7.4]
19-
laravel: [7.*]
19+
laravel: [6.*, 7.*]
2020
dependency-version: [prefer-lowest, prefer-stable]
2121
include:
2222
- laravel: 7.*
2323
testbench: 5.*
24+
- laravel: 6.*
25+
testbench: 4.*
2426

2527
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }}
2628

2729
steps:
2830
- name: Checkout code
29-
uses: actions/checkout@v1
31+
uses: actions/checkout@v2
3032

3133
- name: Cache dependencies
3234
uses: actions/cache@v1
@@ -35,7 +37,7 @@ jobs:
3537
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
3638

3739
- name: Setup PHP
38-
uses: shivammathur/setup-php@v1
40+
uses: shivammathur/setup-php@v2
3941
with:
4042
php-version: ${{ matrix.php }}
4143
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to `laravel-printing` will be documented in this file.
44

5+
## 1.2.0 - 202X-XX-XX
6+
### Added
7+
- Add support for CUPS driver.
8+
59
## 1.1.6 - 2020-07-23
610
### Changed
711
- Remove `int` parameter type hint on `PrintNodePrintJob` `id` setter.

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $printJob->id(); // the id number returned from the print server
2020
Supported Print Drivers:
2121

2222
- PrintNode: https://printnode.com
23+
- CUPS: https://cups.org
2324

2425
## Documentation:
2526

@@ -47,7 +48,7 @@ return [
4748
| Driver
4849
|--------------------------------------------------------------------------
4950
|
50-
| Supported: `printnode`
51+
| Supported: `printnode`, `cups`
5152
|
5253
*/
5354
'driver' => env('PRINTING_DRIVER', 'printnode'),
@@ -64,6 +65,12 @@ return [
6465
'printnode' => [
6566
'key' => env('PRINT_NODE_API_KEY'),
6667
],
68+
'cups' => [
69+
'ip' => env('CUPS_SERVER_IP'),
70+
'username' => env('CUPS_SERVER_USERNAME'),
71+
'password' => env('CUPS_SERVER_PASSWORD'),
72+
'port' => env('CUPS_SERVER_PORT', 631),
73+
],
6774
],
6875

6976
/*
@@ -108,6 +115,8 @@ return [
108115
];
109116
```
110117

118+
- When using CUPS, you can either use a local CUPS server that runs on the **same server as your Laravel installation** (useful for local development), or you can specify an IP address, username, and password for a remote CUPS server. The remote CUPS server **must be on the same network** as any printers you are going to print to.
119+
111120
## Usage
112121

113122
### Listing printers
@@ -150,7 +159,10 @@ Printing::newPrintTask()
150159
->send();
151160
```
152161

153-
More PrintNode options can be found here: https://www.printnode.com/en/docs/api/curl#printjob-options
162+
- More PrintNode options can be found here: https://www.printnode.com/en/docs/api/curl#printjob-options
163+
- More info on using CUPS options can be found here: https://github.com/smalot/cups-ipp
164+
165+
> **Note:** If using CUPS, you can pass in a `$contentType` as a second parameter to the `file()`, `url()`, and `content()` methods. The default is `application/octet-stream` (PDF). More types can be found in `Rawilk\Printing\Drivers\Cups\ContentType.php`.
154166
155167
## Receipt Printing
156168
Receipt printing can be done if you have a receipt printer by using the `Rawilk\Printing\Receipts\ReceiptPrinter` class.

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
"ext-json": "*",
2525
"illuminate/support": "^6.0|^7.0",
2626
"mike42/escpos-php": "^3.0",
27-
"printnode/printnode-php": "^2.0@RC"
27+
"php-http/socket-client": "2.*",
28+
"printnode/printnode-php": "^2.0@RC",
29+
"smalot/cups-ipp": "^0.5.0"
2830
},
2931
"require-dev": {
3032
"friendsofphp/php-cs-fixer": "^2.16",

config/printing.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
| Driver
77
|--------------------------------------------------------------------------
88
|
9-
| Supported: `printnode`
9+
| Supported: `printnode`, `cups`
1010
|
1111
*/
1212
'driver' => env('PRINTING_DRIVER', 'printnode'),
@@ -23,6 +23,12 @@
2323
'printnode' => [
2424
'key' => env('PRINT_NODE_API_KEY'),
2525
],
26+
'cups' => [
27+
'ip' => env('CUPS_SERVER_IP'),
28+
'username' => env('CUPS_SERVER_USERNAME'),
29+
'password' => env('CUPS_SERVER_PASSWORD'),
30+
'port' => env('CUPS_SERVER_PORT', 631),
31+
],
2632
],
2733

2834
/*

phpunit.xml.dist

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php"
3-
backupGlobals="false"
2+
<phpunit backupGlobals="false"
43
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
55
colors="true"
6-
verbose="true"
76
convertErrorsToExceptions="true"
87
convertNoticesToExceptions="true"
98
convertWarningsToExceptions="true"
109
processIsolation="false"
11-
stopOnFailure="false">
10+
stopOnFailure="false"
11+
verbose="true"
12+
>
1213
<testsuites>
1314
<testsuite name="Rawilk Test Suite">
1415
<directory>tests</directory>
1516
</testsuite>
1617
</testsuites>
17-
<filter>
18-
<whitelist>
19-
<directory suffix=".php">src/</directory>
20-
</whitelist>
21-
</filter>
22-
<logging>
23-
<log type="junit" target="build/report.junit.xml"/>
24-
<log type="coverage-html" target="build/coverage"/>
25-
<log type="coverage-text" target="build/coverage.txt"/>
26-
<log type="coverage-clover" target="build/logs/clover.xml"/>
27-
</logging>
2818
</phpunit>

psalm.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
</projectFiles>
1717

1818
<issueHandlers>
19+
<TypeDoesNotContainType errorLevel="suppress"/>
1920
</issueHandlers>
2021

2122
<plugins>

src/Drivers/Cups/ContentType.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Rawilk\Printing\Drivers\Cups;
4+
5+
class ContentType
6+
{
7+
/** @var string */
8+
public const HTML = 'text/html';
9+
10+
/** @var string */
11+
public const PDF = 'application/octet-stream';
12+
13+
/** @var string */
14+
public const TEXT = 'text/plain';
15+
}

0 commit comments

Comments
 (0)