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

Windows下XAMPP环境安装PHP Cassandra Driver遇问题求助

Fixing "Class 'Cassandra' not found" in XAMPP (Windows)

Hey there, let's troubleshoot why your Cassandra PHP driver shows up in php -m but not in phpinfo()—and why your code is throwing that fatal error. Here's a step-by-step breakdown to get it working:

1. Verify Apache is using the correct php.ini file

This is the most common culprit when CLI recognizes the extension but Apache doesn't:

  • Create a simple PHP file with <?php phpinfo(); ?>, put it in your XAMPP htdocs folder, and access it via your browser.
  • Look for the Loaded Configuration File entry. Check if it points to c:\xampp\php\php.ini (the file you modified earlier).
  • If it's a different path (like c:\xampp\apache\bin\php.ini), edit that file instead, add extension=php_cassandra.dll to it, then restart Apache.

2. Double-check driver compatibility

Make sure the precompiled driver matches your PHP environment exactly:

  • Run php -v in your command line to confirm your PHP version (e.g., 7.4.33).
  • Check phpinfo() for two key details:
    • Thread Safety: Should say "Enabled" (XAMPP's PHP is usually thread-safe by default).
    • Architecture: x86 or x64.
  • Re-download the driver that matches all these specs—using a mismatched driver will cause silent loading failures in Apache.

3. Install required Visual C++ Redistributable

The Cassandra PHP driver relies on Microsoft's Visual C++ libraries to run:

  • Check the driver's download page notes to see which VC++ version you need (e.g., VC15 for PHP 7.4).
  • Install the matching Visual C++ Redistributable package, then restart your computer. This fixes most "missing dependency" errors that block the extension from loading in Apache.

4. Add driver dependencies to a system-accessible path

When you extracted the driver package, you probably got more files than just php_cassandra.dll (like cassandra.dll or other core libraries):

  • Copy these additional DLLs to either:
    • C:\Windows\System32 (for x64 systems) or C:\Windows\SysWOW64 (for x86 systems).
    • Or c:\xampp\apache\bin (Apache automatically checks this folder for dependencies).
  • Restart Apache after moving the files.

5. Check Apache error logs for specific clues

If the above steps don't resolve the issue, look for detailed error messages:

  • Open c:\xampp\apache\logs\error.log.
  • Search for keywords like "cassandra" or "php_cassandra.dll"—you'll likely find messages about missing dependencies or invalid extensions, which will point you to the exact problem.

Quick note about PHP class files

You don't need to add any extra PHP class files for this driver! The Cassandra class is provided directly by the compiled extension. The error you're seeing is purely because the extension isn't being loaded properly by Apache, not because you're missing PHP files.


内容的提问来源于stack exchange,提问作者Ligo George

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 07:47:45