Open BrunoFelipeAlbuquerque opened 5 years ago
Well it seems like the parameter you assigned when calling send()
is not an actual PrinterInterface
but is false
. I propose you examine the parameter and check if it actually is implementing the PrinterInterface
.
the same error:
Fatal error: Uncaught TypeError: Argument 1 passed to Smalot\Cups\Manager\JobManager::getList() must implement interface Smalot\Cups\Model\PrinterInterface, bool given, called in /var/www/html/ipp2/printers_jobs.php on line 19 and defined in /var/www/html/ipp2/vendor/smalot/cups-ipp/src/Manager/JobManager.php:31
Stack trace: #0 /var/www/html/ipp2/printers_jobs.php(19):
Smalot\Cups\Manager\JobManager->getList(false, false, 0, 'completed') #1 {main} thrown in /var/www/html/ipp2/vendor/smalot/cups-ipp/src/Manager/JobManager.php on line 31
problem in printer name "...../HP-Photosmart-C4380-series" in sample code. My printer name is "...../ML-371x-Series"
but now i have other error:
Fatal error: Uncaught Http\Client\Common\Exception\ClientErrorException: Unauthorized in /var/www/html/ipp2/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php:72 Stack trace:
#0 /var/www/html/ipp2/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php(54): Http\Client\Common\Plugin\ErrorPlugin->transformResponseToException(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /var/www/html/ipp2/vendor/php-http/httplug/src/Promise/HttpFulfilledPromise.php(34): Http\Client\Common\Plugin\ErrorPlugin->Http\Client\Common\Plugin\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /var/www/html/ipp2/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php(55): Http\Client\Promise\HttpFulfilledPromise->then(Object(Closure))
#3 /var/www/html/ipp2/vendor/php-http/client-common/src/PluginClient.php(161): Http\Client\Common\Plugin\ErrorPlugin->handleRequest(Object(GuzzleHttp\Psr7\Request), Object(Closure), Object(Closure))
#4 /var/www/html/ipp2/vendor/php-http/client-common/src/PluginClient.php(175): Http\Client\Co in /var/www/html/ipp2/vendor/php-http/client-common/src/Plugin/ErrorPlugin.php on line 72
UPDATE: after call function $client->setAuthorizetion('login', 'password')
all work fine.
Thanks to lib author
the same for me
Argument 1 passed to Smalot\Cups\Manager\JobManager::send() must implement interface Smalot\Cups\Model\PrinterInterface, boolean given, called in /var/www/html/ipp_test/test/app/Http/Controllers/testController.php on line 37
my code
$client = new Client();
$builder = new Builder();
$responseParser = new ResponseParser();
// $client->setAuthorizetion('login', 'password');
$printerManager = new PrinterManager($builder, $client, $responseParser);
$printer = $printerManager->findByUri('ipp://192.168.10.232:631');
$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('./helloworld.pdf');
$job->addAttribute('media', 'A4');
$job->addAttribute('fit-to-page', true);
$result = $jobManager->send($printer, $job);
You both are aware that the Client class method for authentication in CUPS is called setAuthentication
and not setAuthorizetion
? Because you both use this wrong method, $client
seems not to authenticate and the $printerManager
probably returns false
instead of a connected printer. And because of this you probably can't send the job via $jobManager->send()
.
:) yes, you right setAuthentication. sorry for my mistakes. Maybe at that time i was works hard and tired
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