smalot / cups-ipp Goto Github PK
View Code? Open in Web Editor NEWCUPS Implementation of IPP - PHP Client API
License: GNU General Public License v2.0
CUPS Implementation of IPP - PHP Client API
License: GNU General Public License v2.0
root@ubuntu:/var/www/html/ipp# composer require smalot/cups-ipp
Using version ^0.4.0 for smalot/cups-ipp
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Installation failed, deleting ./composer.json.
[ErrorException]
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...
how i can check status of job?
Hello,
I'm trying to install package on Symfony 5.
To install it:
# composer require --dev smalot/cups-ipp:dev-master
Do not run Composer as root/super user! See https://getcomposer.org/root for details
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.0.*"
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for smalot/cups-ipp dev-master -> satisfiable by smalot/cups-ipp[dev-master].
- smalot/cups-ipp dev-master requires php-http/socket-client ^1.0 -> satisfiable by php-http/socket-client[v1.0.0, v1.1.0, v1.2.0, v1.3.0, v1.4.0, v1.4.1] but these conflict with your requirements or minimum-stability.
Installation failed, reverting ./composer.json to its original content.
# composer show -i
symfony/options-resolver v5.0.8
php-http/socket-client dev-master
How to add dependency for php-http/socket-client v2.0 ?
Thanks!
Remy
Hi,
For some printers is needed to send the file as raw. By example from terminal I send using this:
lpr -P Zebra-Technologies-ZTC-TLP-2824-Plus -o raw path/to/label.zpl
Which works perfectly, printing the label.
However, trying to send using raw doesnt seems to work with smalot/cups-ipp.
I have created a custom version of config yaml files adding to job.yaml this line:
raw:
tag: 'no-value'
This is needed to get over this:
PHP Fatal error: Uncaught Smalot\Cups\CupsException: Property not found: "raw" .....
After this the Builder was created with the new option set:
$builder = new Builder('./config/cups-ipp/');
$builder->buildProperty('raw', 'no-value');//not sure if actually needed
and the job attribute was set:
$job->addAttribute('raw', null);
However, even after fixing this the (print) output of this is text, the ZPL commands from the submitted file.
My issue is that this provides no documentation on its functions and parameters.
How do I release a job for printing?
What is the license?
Composer says MIT, LICENSE file says GPL 2.0
Ran the last demo, ran into an interesting error:
PHP Fatal error: Declaration of Smalot\\Cups\\Transport\\Client::sendRequest(Psr\\Http\\Message\\RequestInterface $request) must be compatible with Psr\\Http\\Client\\ClientInterface::sendRequest(Psr\\Http\\Message\\RequestInterface $request): Psr\\Http\\Message\\ResponseInterface in /var/www/html/vendor/smalot/cups-ipp/src/Transport/Client.php on line 22
Sorry for a second issue within 24 hours but Im curious if its possible to select a printer tray with your package. I found out that I have to set $job->addAttribute('media-source','tray-2'); but the response i get is : Property not found: "media-source".
The offset is generated by a loop in readAttributeName
and it stops adding to the offset when ($this->offset >= strlen($this->content)
.
When the readAttributeName
function is finished, readValue
is called. Here we have this piece of code: $value_length = ord($this->content[$this->offset]) * 256 + ord($this->content[$this->offset + 1]);
With this flow an error is always thrown because the last character of the content string is content[N-1]. content[N] never exists, let alone content[$this->offset + 1]
.
This happens when trying to get the printer list from PrinterManager::getList().
Any suggestions on how to fix this?
Hello,
Thanks for the work done so far, this looks very clean. I'd be interested in adapting the library to work with a remote CUPS host.
Is it something that would be possible with the current architecture? If yes, could you give me a few pointers so I know where to look for?
Benoit
Hello @smalot ,
Is this project dead ?
I'm getting Error : Interface 'Psr\Http\Client\ClientInterface' not found
I can see the requirements in various package for psr/httpd-client v1.0 but I don't seem to be getting a vendor/psr/httpd-client installed with composer.
With a little digging, it may to be related to an older version of php-http/socket-client that breaks in composer 2? I tried putting a direct entry in to force php-http/socket-client to v1.1 but then it says your ClientInterface usage is incompatible.
I tried adding a direct requirement for psr/httpd-client to my own composer but it still doesn't seem to install it. (i've tried dump-autoload, nuking the lock file and the entire vendor folder - i even installed psr/httpd-client into another temporary directory, copying it to /vendor and doing composer dump-autoload. Still no glory. Not sure how to fix it locally - not sure what needs to be done to fix it in your stuff)
I am able to connect to a remote server using
$client = new Client("username", "password", ["remote_socket" => "tcp://remote_ip:631"]);
but $printers = $printerManager->getList();
is only showing local printers.
Edit:
This is a little confusing. Setting a printer as default will cause to appear in the getList(), but only that printer, nothing else.
Hi,
Thanks for your package, it worked out of the box without too much issues! 👍
I'm trying to print a PDF in landscape to a Zebra printer.
I've tried to add an attribute landscape = true
and orientation-requested = 4
but it fails.
Guzzle exception says: Bad Request
Cups error log shows: IPP read error: IPP enum value not 4 bytes
If I don't supply the attribute the label is printed but in portrait. I've also tried to use the 0x04
syntax but it returns the same error.
Any pointers?
Ubuntu 14.04
Cups 1.5.3
PHP 5.6.33 (Yeah I know, I know)
My code:
<?php
include '../../vendor/autoload.php';
use Smalot\Cups\Builder\Builder;
use Smalot\Cups\Manager\JobManager;
use Smalot\Cups\Manager\PrinterManager;
use Smalot\Cups\Model\Job;
use Smalot\Cups\Transport\Client;
use Smalot\Cups\Transport\ResponseParser;
$client = new Client();
$builder = new Builder();
$responseParser = new ResponseParser();
$printerManager = new PrinterManager($builder, $client, $responseParser);
$printer = $printerManager->findByUri('ipp://printserver:631/printers/GK420T');
$jobManager = new JobManager($builder, $client, $responseParser);
$job = new Job();
$job->setName('job create file');
$job->setUsername('demo');
$job->setCopies(1);
$job->setPageRanges(1);
$job->addFile('label_5a79e4c0ae949');
$job->addAttribute('orientation-requested', 4);
$result = $jobManager->send($printer, $job);
Which Value can i add to make multi print
$job->setPageRanges(???????);
After installing and trying to use any of the example code, I'm getting the following error:
Fatal error: Uncaught TypeError: Argument 1 passed to Smalot\Cups\Manager\JobManager::send() must implement interface Smalot\Cups\Model\PrinterInterface, boolean given, called in /var/www/cups/index.php on line 29 and defined in /var/www/cups/vendor/smalot/cups-ipp/src/Manager/JobManager.php:87 Stack trace: #0 /var/www/cups/index.php(29): Smalot\Cups\Manager\JobManager->send(false, Object(Smalot\Cups\Model\Job)) #1 {main} thrown in /var/www/cups/vendor/smalot/cups-ipp/src/Manager/JobManager.php on line 87
I am using the library inside a Laravel 5.6 application.
When I try to print a document I get an exception (HTTP-Statuscode 400 - "Bad Request").
$client = new Client('scholz', '123456');
$builder = new Builder();
$responseParser = new ResponseParser();
$printerManager = new PrinterManager($builder, $client, $responseParser);
$printer = $printerManager->findByUri('ipp://localhost:631/printers/inpas');
$jobManager = new JobManager($builder, $client, $responseParser);
$job = new Job();
$job->setName($printjob->title);
$job->setUsername('scholz');
$job->addFile('./storage/app/'.$printjob->file);
$job->addAttribute('media', $printjob->format);
$job->addAttribute('orientation-requested', $printjob->orientation);
$job->addAttribute('fit-to-page', true);
$job->setPageRanges($printjob->range);
$result = $jobManager->send($printer, $job);
Check a screenshot of the Exception here:
https://www2.pic-upload.de/img/35784064/Bildschirmfotovom2018-08-1316-47-35.png
Any ideas what I could try? The provided data in the $printjob Object is correct, too, because I fixed any errors with this by now. Also I added www-data user (Apache) to lp usergroup in Ubuntu.
I am just wondering how I'd maybe get around this 400 error and finally print a pdf...
I am not sure if this issue is directly related to this package but I can't find solutions, so here asking for support. Your List Printers code throws an error No such file or directory
and is thrown from Client.php
protected function createSocket(RequestInterface $request, $remote, $useSsl)
{
$errNo = null;
$errMsg = null;
$socket = @stream_socket_client($remote, $errNo, $errMsg, floor($this->config['timeout'] / 1000), STREAM_CLIENT_CONNECT, $this->config['stream_context']);
if (false === $socket) { \\ <-------- THROWS AN ERROR HERE!
throw new ConnectionException($errMsg, $request);
}
stream_set_timeout($socket, floor($this->config['timeout'] / 1000), $this->config['timeout'] % 1000);
if ($useSsl && false === @stream_socket_enable_crypto($socket, true, $this->config['ssl_method'])) {
throw new SSLConnectionException(sprintf('Cannot enable tls: %s', error_get_last()['message']), $request);
}
return $socket;
}
Hey,
I've got the problem my customer needs an automatic print and he always shut down the printer so I need a restart after switch on. How do I get that Jobinterface for new JobManager->restart()?
I tried:
function restartQuery($printer_name)
{
$showauträge_limit = 20;
global $builder, $client, $responseParser;
$printerManager = new PrinterManager($builder, $client, $responseParser);
$printer = $printerManager->findByUri('ipp://localhost:631/printers/'.$printer_name);
$jobManager = new JobManager($builder, $client, $responseParser);
$job = $jobManager->getList($printer, false, $showauträge_limit, 'completed');
$jobManager->restart($job);
}
maybe you an help me how to fix that
Hello,
I found a problem when I wanted to connect to a print server using HTTPS and a self-signed certificate.
$client = new Client("printer", "edsfsdfgdsfdsfgdsfg", [
"remote_socket" => "XXX.XXX.XXX.XXX:631",
"ssl" => true,
'stream_context_options' => [
'ssl' => [
'allow_self_signed' => false,
'verify_peer' => false,
'verify_peer_name' => false
]
],
]);
My stream_context_options
parameters was not working.
I found the solution in file /src/Transport/Client.php on line 73 :
$socketClient = new SocketHttpClient($messageFactory, $socketClientOptions);
replaced by :
$socketClient = new SocketHttpClient($messageFactory, null, $socketClientOptions);
because the SocketHttpClient constructor is :
/**
* Constructor.
*
* @param array $config {
*
* @var string $remote_socket Remote entrypoint (can be a tcp or unix domain address)
* @var int $timeout Timeout before canceling request
* @var array $stream_context_options Context options as defined in the PHP documentation
* @var array $stream_context_param Context params as defined in the PHP documentation
* @var bool $ssl Use ssl, default to scheme from request, false if not present
* @var int $write_buffer_size Buffer when writing the request body, defaults to 8192
* @var int $ssl_method Crypto method for ssl/tls, see PHP doc, defaults to STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
* }
*/
public function __construct($config1 = [], $config2 = null, array $config = [])
{
if (\is_array($config1)) {
$this->config = $this->configure($config1);
return;
}
@trigger_error('Passing a Psr\Http\Message\ResponseFactoryInterface and a Psr\Http\Message\StreamFactoryInterface to SocketClient is deprecated, and will be removed in 3.0, you should only pass config options.', E_USER_DEPRECATED);
$this->config = $this->configure($config);
}
Kind regards
When I want to print a pdf I only get unauthorized. Made an question on stackoverflow. https://stackoverflow.com/questions/50719482/ipp-printing-returns-unauthorized
Could you help me?
Hello,
thanks for your package. It works greatfully for my label print application. But for one printer I need a margin left to printing the label. It is lightly displaced. How can I set a margin left for ipp?
I tried many things ... But response was always "property unknown". I´m using cups as print server. It´s a Zebra TLP 2844 printer.
Hope you can help me. Thank you.
After update from 0.4 to 0.5 I get this error:
"Declaration of Smalot\Cups\Transport\Client::sendRequest(Psr\Http\Message\RequestInterface $request) must be compatible with Psr\Http\Client\ClientInterface::sendRequest(Psr\Http\Message\RequestInterface $request): Psr\Http\Message\ResponseInterface"
This is because of version constraints of dependencies has been removed
- Upgrading php-http/promise (v1.0.0 => 1.1.0): Extracting archive
- Upgrading php-http/httplug (v1.1.0 => 2.2.0): Extracting archive
- Upgrading php-http/socket-client (v1.4.1 => 2.1.0): Extracting archive
- Upgrading php-http/message (1.8.0 => 1.11.1): Extracting archive
- Upgrading php-http/client-common (1.10.0 => 2.4.0): Extracting archive
- Upgrading smalot/cups-ipp (v0.4 => v0.5): Extracting archive
php-http/httplug ^2.0 introduces a new interface for ClientInterface
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.