Skip to content

Commit 510b5f3

Browse files
authored
Merge pull request #4 from 123inkt/init-repo-no-skeleton
Setup the initial repo for publication v2
2 parents 07b9c48 + fb25c1f commit 510b5f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2467
-29
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
php-versions: [ '8.1', '8.2', '8.3', '8.4' ]
21+
php-versions: [ '8.3', '8.4' ]
2222
composer-flags: [ '', '--prefer-lowest' ]
2323
steps:
2424
- uses: actions/checkout@v4
@@ -46,17 +46,17 @@ jobs:
4646
- name: Setup PHP
4747
uses: shivammathur/setup-php@v2
4848
with:
49-
php-version: 8.2
49+
php-version: 8.3
5050
coverage: pcov
5151

5252
- name: Install dependencies
5353
run: composer update --prefer-dist --no-progress --no-suggest --prefer-stable
5454

5555
- name: Run test suite
56-
run: php -dpcov.enabled=1 -dpcov.exclude="~vendor~" vendor/bin/phpunit --testsuite unit --coverage-clover ./.coverage/coverage.xml
56+
run: php -dpcov.enabled=1 -dpcov.exclude="~vendor~" vendor/bin/phpunit --testsuite unit --coverage-clover ./coverage.xml
5757

5858
- name: Check coverage
59-
run: test ! -f ./.coverage/coverage.xml || php vendor/bin/phpfci inspect ./.coverage/coverage.xml ./.coverage/phpfci.xml --exit-code-on-failure
59+
run: test ! -f ./.coverage/coverage.xml || php vendor/bin/phpfci inspect ./coverage.xml ./phpfci.xml --exit-code-on-failure
6060

6161
quality:
6262
name: Quality checks
@@ -67,7 +67,7 @@ jobs:
6767
- name: Setup PHP
6868
uses: shivammathur/setup-php@v2
6969
with:
70-
php-version: 8.1
70+
php-version: 8.3
7171
coverage: none
7272

7373
- name: Install dependencies

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/.idea
22
/vendor
3-
/composer.lock
4-
/phpunit.xml
53
/.phpunit.result.cache
4+
/.phpunit.cache
5+
/composer.lock
6+
/coverage.xml

README.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,93 @@
1-
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF)](https://php.net/)
1+
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.3-8892BF)](https://php.net/)
2+
3+
# Digitalrevolution IPP library
4+
5+
## Installation
6+
7+
```bash
8+
composer require digitalrevolution/ipp
9+
```
10+
11+
## Usage
12+
13+
### Initialize the library
14+
15+
```php
16+
$server = new IppServer();
17+
$server->setUri('https://cups.local');
18+
$server->setUsername('admin'); // optional
19+
$server->setPassword('admin'); // optional
20+
21+
$ipp = new Ipp($server, new Psr18Client());
22+
```
23+
24+
### Print a file
25+
26+
```php
27+
// define a printer
28+
$printer = new IppPrinter();
29+
$printer->setHostname('my.printer');
30+
31+
// print a file on the selected printer
32+
$ippFile = new IppPrintFile(file_get_contents('/dir/file.ps'), FileTypeEnum::PS);
33+
$ipp->print($printer, $ippFile);
34+
```
35+
36+
### Fetch job attributes
37+
38+
```php
39+
$printJob = $ipp->print($printer, $ippFile);
40+
$updatedPrintJob = $ipp->getJobAttributes($printJob->getJobUri());
41+
```
42+
43+
### Register a printer with cups
44+
45+
```php
46+
$printer = new IppPrinter();
47+
$printer->setHostname('my.printer');
48+
$printer->setDeviceUri('my.uri');
49+
$printer->setLocation('location');
50+
51+
$ipp->createPrinter($printer);
52+
```
53+
54+
### Delete a printer
55+
56+
```php
57+
$printer = new IppPrinter();
58+
$printer->setHostname('my.printer');
59+
60+
$ipp->deletePrinter($printer);
61+
```
62+
63+
### Contributing
64+
65+
See [contributing.md](./CONTRIBUTING.md)
66+
Pull requests welcome for adding standard IPP Operations
67+
68+
### Creating a custom IPP operation
69+
70+
This project is created to be easily extensible, adding a new IPP operation is as simple as making sure it has an identifier in IppOperationEnum
71+
Then adding any Job, Printer or Operation Attributes as required by your standard.
72+
Finally sending the request and parsing the response using the standard parser.
73+
74+
```php
75+
public function myOperation(): IppResponseInterface
76+
$operation = new IppOperation(IppOperationEnum::OperationType);
77+
$operation->addOperationAttribute(new IppAttribute(IppTypeEnum::Charset, 'attributes-charset', 'utf-8'));
78+
79+
$response = $this->client->sendRequest(
80+
new Request(
81+
'POST',
82+
$this->server->getUri(),
83+
['Content-Type' => 'application/ipp'],
84+
(string)$operation
85+
)
86+
);
87+
88+
return $this->parser->getResponse($response->getBody()->getContents());
89+
}
90+
```
291

392
## About us
493

composer.json

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,35 @@
11
{
2-
"name": "digitalrevolution/skeleton",
3-
"description": "Digital Revolution skeleton package",
2+
"name": "digitalrevolution/ipp",
3+
"description": "Digital Revolution IPP library",
44
"type": "library",
55
"license": "MIT",
66
"minimum-stability": "stable",
77
"config": {
88
"sort-packages": true,
9+
"process-timeout": 0,
910
"allow-plugins": {
10-
"phpstan/extension-installer": true
11-
}
11+
"phpstan/extension-installer": true,
12+
"dealerdirect/phpcodesniffer-composer-installer": true,
13+
"digitalrevolution/php-codesniffer-baseline": true
14+
},
15+
"lock": false
1216
},
1317
"require": {
14-
"php": ">=8.1"
18+
"php": "^8.3",
19+
"nyholm/psr7": "^1.8",
20+
"psr/http-client": "^1.0",
21+
"psr/log": "^3.0",
22+
"digitalrevolution/utils": "^1.0"
1523
},
1624
"require-dev": {
17-
"digitalrevolution/phpunit-file-coverage-inspection": "^v2.0.0",
18-
"phpmd/phpmd": "^2.14",
19-
"phpstan/extension-installer": "^1.3",
20-
"phpstan/phpstan": "^2.0",
21-
"phpstan/phpstan-phpunit": "^2.0",
22-
"phpstan/phpstan-strict-rules": "^2.0",
23-
"phpunit/phpunit": "^11.5 || ^12.0",
25+
"digitalrevolution/accessorpair-constraint": "^v2.4.1",
26+
"digitalrevolution/phpunit-file-coverage-inspection": "^3.0",
27+
"digitalrevolution/php-codesniffer-baseline": "^1.1",
28+
"phpmd/phpmd": "^2.12",
29+
"phpstan/extension-installer": "^1.2",
30+
"phpstan/phpstan": "^1.9.1",
31+
"phpstan/phpstan-phpunit": "^1.2.2",
32+
"phpunit/phpunit": "^11.5",
2433
"roave/security-advisories": "dev-latest",
2534
"squizlabs/php_codesniffer": "^3.7",
2635
"slevomat/coding-standard": "^8.16"
@@ -31,19 +40,33 @@
3140
"@baseline:phpmd"
3241
],
3342
"baseline:phpstan": "phpstan --generate-baseline",
34-
"baseline:phpmd": "phpmd src,tests xml phpmd.xml.dist --generate-baseline",
43+
"baseline:phpmd": "phpmd src,tests xml phpmd.xml --generate-baseline",
3544
"check": [
3645
"@check:phpstan",
3746
"@check:phpmd",
3847
"@check:phpcs"
3948
],
4049
"check:phpstan": "phpstan analyse",
41-
"check:phpmd": "phpmd src,tests text phpmd.xml.dist --suffixes php",
50+
"check:phpmd": "phpmd src,tests text phpmd.xml --suffixes php",
4251
"check:phpcs": "phpcs src tests",
4352
"fix": "@fix:phpcbf",
4453
"fix:phpcbf": "phpcbf src tests",
45-
"test": "phpunit",
46-
"test:integration": "phpunit --testsuite integration",
47-
"test:unit": "phpunit --testsuite unit"
54+
"test": "phpunit --testsuite unit",
55+
"test:coverage": [
56+
"phpunit --testsuite unit --coverage-clover coverage.xml",
57+
"phpfci inspect coverage.xml --exit-code-on-failure"
58+
],
59+
"test:phpfci": "phpfci inspect coverage.xml --exit-code-on-failure"
60+
},
61+
"autoload": {
62+
"psr-4": {
63+
"DR\\Ipp\\": "src/"
64+
}
65+
},
66+
"autoload-dev": {
67+
"psr-4": {
68+
"DR\\Ipp\\Tests\\Unit\\": "tests/Unit/",
69+
"DR\\Ipp\\Tests\\": "tests/"
70+
}
4871
}
4972
}

phpcs.xml.dist renamed to phpcs.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
</rule>
2121
<rule ref="SlevomatCodingStandard.Complexity.Cognitive">
2222
<properties>
23-
<property name="warningThreshold" value="16"/>
24-
<property name="errorThreshold" value="16"/>
23+
<property name="warningThreshold" value="6"/>
24+
<property name="errorThreshold" value="6"/>
2525
</properties>
2626
</rule>
2727
<rule ref="SlevomatCodingStandard.Arrays.DisallowImplicitArrayCreation"/>

phpfci.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
21
<phpfci xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
32
xsi:noNamespaceSchemaLocation="vendor/digitalrevolution/phpunit-file-coverage-inspection/resources/phpfci.xsd"
43
min-coverage="100">
File renamed without changes.

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ parameters:
33
treatPhpDocTypesAsCertain: false
44
paths:
55
- src
6-
- test
6+
- tests
File renamed without changes.

src/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)