PHP-Driver DataStax Cassandra DB - How to use?

瘦欲@ 提交于 2019-12-07 20:44:32

Since you are trying to execute your PHP script using nginx+fpm you will need to update the appropriate php.ini file (e.g. /etc/php7/fpm/php.ini).

Add the driver module to your nginx+fpm installation

echo -e "; DataStax PHP Driver\nextension=cassandra.so" >> /etc/php/7.0/fpm/php.ini

To ensure the the driver is being properly loaded via CLI you can execute the following:

php -m | grep cassandra

or

php -i | grep -A 10 "^cassandra$"

php -m will print out all the extension/modules that PHP was able to load whereas php -i will display more verbose information about your PHP installation configuration.

UPDATE 1

When I execute the following 2 commands I get the following two results, which looks quite successful.

php -m | grep cassandra

cassandra

php -i | grep -A 10 "^cassandra$"

cassandra

Cassandra support => enabled C/C++ driver version => 2.2.2 Persistent Clusters => 0 Persistent Sessions => 0

Directive => Local Value => Master Value cassandra.log => cassandra.log => cassandra.log cassandra.log_level => ERROR => ERROR

But still the error no class Cassandra.

UPDATE 2

Everything working now.

php > $cluster = Cassandra::cluster()->build(); 
php > var_dump($cluster); 
object(Cassandra\DefaultCluster)#2 (0) { } 
php >
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!