问题
I have made a Laravel command that I try to run with a cronjob every minute.
In the command there is some logic that does a soap call. When I run the command through a route that I created everything works fine.
like this:
Route::get('test-command', function() {
Artisan::call('updateRegisterLogs');
});
Now when I try to do the same thing in my command on the server like this:
php artisan updateRegisterLogs
I get the following error:
Class 'SoapClient' not found
Now I searched on the internet and in my php.ini I removed the ;
before extension=php_soap.dll
and before extension=php_openssl.dll
and I've restarted my apache and unfortunately I get the same error.
I am now sure what is going wrong here since my code works but not when executed with artian.
回答1:
Usually php has various php.ini
configuration files, typically located on paths like, /etc/php/7.2/cli/php.ini
or /etc/php/7.2/fpm/php.ini
so from the problem you are having my guess is that you have uncommented the extension on one of those config files but not the cli path one.
If you have for example the application being served using nginx and phpfpm the php.ini
file that will determine what modules are enabled when executing php for those requests will be the one located at /etc/php/7.2/fpm/php.ini
. When you execute artisan commands the "selected" config file is the one at /etc/php/7.2/cli/php.init
来源:https://stackoverflow.com/questions/55572708/php-can-not-perform-soap-call-from-laravel-command