MacOS上的Cassandra php驱动程序 - 类'Cassandra \ SimpleStatement'找不到

问题描述:

美好的一天,每个人。MacOS上的Cassandra php驱动程序 - 类'Cassandra SimpleStatement'找不到

通常我只是用这个在* Official Docs Unix操作系统的

但我现在使用Mac系统,这说明只是不能正常工作。

pecl install cassandra情况下,我得到这个消息:

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 

我的逻辑告诉我,在这种情况下,我需要我自己做DataStax C/C++的驱动程序。在文件夹php-driver\lib我删除cpp-driver并使用this instruction使新的和新鲜的C/C++驱动程序没有错误。

所以在官方文档,它说:

Note The install.sh 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.

但是,当我试图运行从php-drive/ext./configure我得到了几乎相同的错误:

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) 

即使我继续下去,错误运行后make install它给我那个日志:

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

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 ld.so(8) manual pages. 
---------------------------------------------------------------------- 
Installing shared extensions:  /usr/lib/php/extensions/no-debug-non-zts-20121212/ 
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#[email protected]#: Operation not permitted 
make: *** [install-modules] Error 1 

Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/modules

即使我将cassandra扩展与该路径添加到php.ini中,我仍然在我的项目中出现了错误Class 'Cassandra\SimpleStatement' not found

php -d="extension=modules/cassandra.so" -m表明cassandra在PHP模块列表

我在做什么错?

PS:我已经在Parallels这个项目中安装了带有DataStax php驱动程序的ubuntu操作系统,并且安装了这个指令。

____upd: 没有任何错误 @Fero的所有指令后,指挥/usr/local/bin/php -i | grep -A 10 "^cassandra$"我看这个:

cassandra 

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 

还是一样的错误 - Class 'Cassandra\SimpleStatement' not found

______________UPDATED LAST:

Aaaaand它的工作!我在我的项目中编写了输出phpinfo();,并意识到使用其他php版本和php.ini的apache,根本不是extension=cassandra.so

您将需要安装DataStax C/C++驱动程序,该驱动程序是PHP驱动程序的依赖项。驱动程序成功构建后,使用these instructions后跟make install将确保在构建PHP驱动程序时可以使用此依赖关系。使用PHP驱动程序build instructions,您需要确保在运行pecl install cassandra之前,还可以使用GMP和PHP开发库。

编辑:

由于您使用埃尔卡皮坦你碰到的问题与System Integrity Protection,你会需要它disable才能将文件复制到/usr。更好的和推荐的选择是使用Homebrew来安装PHP;但如果您喜欢,也可以使用MacPorts

下面是用于再现PHP驱动程序的安装与Xcode和自制清洁OSX埃尔卡皮坦图像上已经安装的步骤:

brew install autoconf cmake libuv gmp openssl pcre homebrew/php/php55 
brew link homebrew/php/php55 
mkdir code 
pushd code 
git clone https://github.com/datastax/php-driver.git 
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 
popd 
popd 
mkdir build 
pushd ext 
/usr/local/bin/phpize 
popd 
pushd build 
../ext/configure --with-php-config=/usr/local/bin/php-config 
make -j$(sysctl -n hw.ncpu) 
sudo make install 
popd 
popd 
sudo sh -c 'echo "extension=cassandra.so" >> /usr/local/etc/php/5.5/php.ini' 

然后,您可以使用以下命令验证安装:

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

注意:上面利用了PHP v5.5,因为这是El Capitan自带的默认版本;也可以使用PHP v5.6和v7.0。

+0

已经完成了这个... 正如我已经写过的 - 当'pecl install cassandra'没有使用内置的cpp-driver时,我使用这些指令并自己构建cpp-driver - 他成功地构建了。 而且无论如何不起作用。查看帖子中的错误 – ANTVirGEO

+0

@ANTVirGEO我编辑了原始答案,以帮助您理解'sudo make install'过程中的复制操作为什么会失败,并为您提供从源代码构建的分步/脚本指示。 – Fero

+0

首先 - 感谢您一步一步的指导 - 这非常有帮助! 最初发布后更新。 我关闭了SIP,并完成所有步骤,但仍得到相同的错误= \ – ANTVirGEO