You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 8项目调用SOAP API提示‘Class SoapClient not found’错误求助(已启用XAMPP SOAP扩展)

Fixing "Class 'SoapClient' not found" in Laravel 8 with XAMPP

Let's walk through the most common fixes for this issue, since you already tried enabling the SOAP extension in XAMPP but it's still not working:

1. Double-check you edited the correct php.ini file

XAMPP has two separate php.ini files—one for the Apache web server, and one for the CLI (command line interface). If you edited the wrong one, the SOAP extension won't load for your Laravel app:

  • For Apache (when accessing your app via browser or artisan serve), the file is usually at C:\xampp\apache\bin\php.ini
  • For CLI (if you're running queue workers, migrations, etc.), it's at C:\xampp\php\php.ini

To confirm which one your app is using:

  • Create a temporary phpinfo.php file in your Laravel public folder with this code:
    <?php phpinfo(); ?>
    
  • Access it via your browser (e.g., http://localhost/API/public/phpinfo.php), then search for "soap". If you don't see sections for "Soap Client" and "Soap Server", you edited the wrong php.ini.

2. Properly enable the SOAP extension

Once you have the correct php.ini file:

  • Find the line that looks like ;extension=soap (or ;extension=php_soap.dll for Windows)
  • Remove the leading semicolon (;) to uncomment the line
  • Save the file, then restart XAMPP's Apache service (this is critical—changes won't take effect until you restart!)

3. Verify CLI PHP has SOAP enabled (if needed)

If you're running Laravel commands via CLI (like php artisan serve or queue jobs), check if SOAP is enabled there too:

  • Open Command Prompt (CMD) and run:
    php -m
    
  • Look for "soap" in the list of modules. If it's missing, edit the C:\xampp\php\php.ini file as described above, then close and reopen your CMD window (restarting the shell is needed for changes to apply).

4. Double-check your code

Your current code uses \SoapClient (global namespace), which is correct—just make sure you didn't misspell it (it's case-sensitive: SoapClient, not soapclient or Soapclient).

Final Troubleshooting Tip

If none of the above works, try restarting your entire computer (sometimes XAMPP holds onto old PHP processes). Also, confirm that your XAMPP PHP version is compatible with the SOAP extension (most modern XAMPP versions include it by default, so this is rarely an issue).

内容的提问来源于stack exchange,提问作者Hoda Kh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 16:52:32