Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JobManager::send() must implement interface Smalot\Cups\Model\PrinterInterface #9

Open
BrunoFelipeAlbuquerque opened this issue Sep 19, 2018 · 5 comments

Comments

@BrunoFelipeAlbuquerque
Copy link

BrunoFelipeAlbuquerque commented Sep 19, 2018

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

@BrunoFelipeAlbuquerque BrunoFelipeAlbuquerque changed the title Uncaught Http\Client\Socket\Exception\ConnectionException: Connection refused JobManager::send() must implement interface Smalot\Cups\Model\PrinterInterface Sep 19, 2018
@c-scholz-acribit
Copy link

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.

@boomsya
Copy link

boomsya commented May 8, 2019

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

@HayderHatem
Copy link

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);

@c-scholz-acribit
Copy link

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().

@boomsya
Copy link

boomsya commented Jul 3, 2019

:) yes, you right
setAuthentication. sorry for my mistakes. Maybe at that time i was works hard and tired

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants