【发布时间】:2019-01-28 19:11:27
【问题描述】:
我已经在 Ubuntu 18.04 中从 apt-get 安装了 php-cassandra。
sudo apt-get install php-cassandra
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
php-cassandra
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3,892 B of archives.
After this operation, 21.5 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu bionic/universe amd64 php-cassandra amd64 1.3.0-1build1 [3,892 B]
Fetched 3,892 B in 0s (11.0 kB/s)
Selecting previously unselected package php-cassandra.
(Reading database ... 256791 files and directories currently installed.)
Preparing to unpack .../php-cassandra_1.3.0-1build1_amd64.deb ...
Unpacking php-cassandra (1.3.0-1build1) ...
Setting up php-cassandra (1.3.0-1build1) ...
================================================ ==
php test_cass.php
PHP Warning: PHP Startup: Unable to load dynamic library 'cassandra.so' (tried: /usr/lib/php/20170718/cassandra.so (/usr/lib/php/20170718/cassandra.so: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/cassandra.so.so (/usr/lib/php/20170718/cassandra.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Fatal error: Uncaught Error: Class 'Cassandra' not found in /home/prabhakarc/php_programs/test_cass.php:3
Stack trace:
#0 {main}
thrown in /home/prabhakarc/php_programs/test_cass.php on line 3
提前致谢。
编辑:
test_cass.php 的内容:
<?php
$cluster = new Cassandra::cluster()->withContactPoints('127.0.0.1')->build();
$session = $cluster->connect("<Keyspace>");
$statement = new Cassandra\SimpleStatement("SELECT * FROM <table>");
$result = $session->execute($statement);
echo "Result contains " . $result->count() . " rows"; ?> –
【问题讨论】:
-
你能用 test_cass.php 的前 5 行来编辑你的帖子吗?听起来您没有正确引用 Cassandra 库。
-
<?php $cluster = Cassandra::cluster()->withContactPoints('127.0.0.1')->build(); $session = $cluster->connect("<Keyspace>"); $statement = new Cassandra\SimpleStatement("SELECT * FROM <table>"); $result = $session->execute($statement); echo "Result contains " . $result->count() . " rows"; ?>
标签: php cassandra ubuntu-18.04