3
votes

I'm using Laravel workers to execute some background tasks. When I invoke the worker using 'php artisan queue:work', it works without any problem

But when I add the same command to supervisord in CentOS, using the following congifuration:

[program:laravel-worker]

process_name=%(program_name)s_%(process_num)02d command=php

/var/www/html/laravel/artisan queue:work

autostart=true

autorestart=true

user=root

numprocs=8

redirect_stderr=true

stdout_logfile=/var/www/html/laravel/worker.log

I get the following error:

PHP Fatal error: Class 'SoapClient' not found in /var/www/html/laravel/app/External/library/RegistrationServi‌​ce.php on line 169

[Symfony\Component\Debug\Exception\FatalErrorException] Class 'SoapClient' not found

The jobs are not executed complaining that SoapClient is not found (although it is installed). The SoapClient class is inherited by a plain PHP class that I load externally.

Note that I can use this class via the controller or the jobs when executed from command line without any problem, only in supervisord it's giving me the error message. To make things more weird, it happens only with one job that utilizes this external class, it doesn't happen with jobs that utilize Laravel's classes (controllers, events, etc...) only.

2
It might be worth sharing the errors where you stated "complaining that SoapClient is not found" or the code that invokes ithaakym
PHP Fatal error: Class 'SoapClient' not found in /var/www/html/laravel/app/External/library/RegistrationService.php on line 169 [Symfony\Component\Debug\Exception\FatalErrorException] Class 'SoapClient' not foundFiFo
better to edit your question with ithaakym

2 Answers

0
votes

For SoapClient in Laravel 5.2:

  1. add 'SoapClient' => SoapClient::class, in Config/app.php

  2. add use SoapClient; in your controller.

  3. use soapClinet in your function: new SoapClient('...');

0
votes

I could solve it by specifying the exact path of the php binary I still don't understand why it didn't pick the default one