ANTVirGEO ANTVirGEO - 1 year ago 185
PHP Question

Cassandra php driver on MacOS - Class 'Cassandra\SimpleStatement' not found

Good day, everyone.

Usually I just using this Official Docs in *nix OS

But now i'm using MacOs and this instructions just doesn't work properly.

In case of

pecl install cassandra
I got this message:

checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
ERROR: `/private/tmp/pear/install/cassandra/configure --with-php-config=/usr/bin/php-config' failed

My logic tell me that in that case I need make DataStax C/C++ driver by my own. In folder
I deleting
and using this instruction make new and fresh C/C++ driver without errors.

So in official doc it says:

Note The script will also compile and statically link into the extension a submoduled version of the DataStax C/C++ driver for Apache Cassandra. To use a version of cpp driver that you already have on your system, run phpize, ./configure and make install.

But when i trying to run
I got almost the same error:

checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )

Even if I continue and after that error run
make install
it gives me that log:

/bin/sh /Users/antvirgeo/php-driver/ext/libtool --mode=install cp ./ /Users/antvirgeo/php-driver/ext/modules
cp ./.libs/ /Users/antvirgeo/php-driver/ext/modules/
cp ./.libs/cassandra.lai /Users/antvirgeo/php-driver/ext/modules/
Libraries have been installed in:

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution

See any operating system documentation about shared libraries for
more information, such as the ld(1) and manual pages.
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST@24727#: Operation not permitted
make: *** [install-modules] Error 1

Libraries have been installed in:


Even if I adding cassandra extension with that path to php.ini I still got error
Class 'Cassandra\SimpleStatement' not found
in my project.

php -d="extension=modules/" -m
showing that
in list of PHP Modules

What am I doing wrong?

PS: I have ubuntu OS in Parallels with this project with DataStax php driver installed with this instructions works fine.

After all instructions of @Fero without ANY ERRORS, command
/usr/local/bin/php -i | grep -A 10 "^cassandra$"
showing me this:


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

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

And still the same error -
Class 'Cassandra\SimpleStatement' not found

______________UPDATED LAST:

Aaaaand it's working! I wrote output
in my project and realize that apache using other php version and
, where wasn't
at all.

Answer Source

You will need to install the DataStax C/C++ driver which is a dependency of the PHP driver. Using these instructions followed by make install after the driver has been successfully built will ensure this dependency is available when building the PHP driver. Using the PHP driver build instructions you will need to make sure that GMP and PHP dev libraries are also available before running pecl install cassandra.


Since you are using El Capitan you are running into issues with the System Integrity Protection and you will need to disable it in order to copy files into /usr. The better and recommended option is to install PHP using Homebrew; however you can also use MacPorts if preferred.

Below are the steps used to reproduce the installation of the PHP driver on a clean OSX El Capitan image with Xcode and Homebrew already installed:

brew install autoconf cmake libuv gmp openssl pcre homebrew/php/php55
brew link homebrew/php/php55
mkdir code
pushd code
git clone
pushd php-driver
git submodule update --init --recursive
pushd lib/cpp-driver
mkdir build
pushd build
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
make -j$(sysctl -n hw.ncpu)
sudo make install
mkdir build
pushd ext
pushd build
../ext/configure --with-php-config=/usr/local/bin/php-config
make -j$(sysctl -n hw.ncpu)
sudo make install
sudo sh -c 'echo "" >> /usr/local/etc/php/5.5/php.ini'

You can then verify the installation using the following command:

/usr/local/bin/php -i | grep -A 10 "^cassandra$"

NOTE: PHP v5.5 is utilized above since that is the default version that comes with El Capitan; PHP v5.6 and v7.0 can also be used instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download