MacOS上的Cassandra php驱动程序-未找到类'Cassandra \ SimpleStatement' [英] Cassandra php driver on MacOS - Class 'Cassandra\SimpleStatement' not found

查看:131
本文介绍了MacOS上的Cassandra php驱动程序-未找到类'Cassandra \ SimpleStatement'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

通常,我只在以下位置使用此官方文档 * nix操作系统

Usually I just using this Official Docs in *nix OS

但是现在我正在使用MacO,并且此说明无法正常工作.

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

pecl install cassandra的情况下,我收到此消息:

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

我的逻辑告诉我,在那种情况下,我需要自己制作DataStax C/C ++驱动程序.在文件夹php-driver\lib中,我删除cpp-driver并使用此说明新建以及没有错误的全新C/C ++驱动程序.

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

因此,在官方文档中说:

So in official doc it says:

注意install.sh脚本还将编译并静态链接用于Apache Cassandra的DataStax C/C ++驱动程序的子调制版本.要使用系统上已有的cpp驱动程序版本,请运行phpize,./configure并进行安装.

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时,我得到了几乎相同的错误:

But when i trying to run ./configure from php-drive/ext 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 )

即使我继续操作并在发生错误后运行make install,它也会给我该日志:

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 ./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/#INST@24727#: Operation not permitted
make: *** [install-modules] Error 1

库已安装在:
/Users/antvirgeo/php-driver/ext/modules

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

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

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/cassandra.so" -m显示cassandra在PHP模块列表中

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

我在做什么错了?

PS:我在Parallels的这个项目中安装了ubuntu操作系统,并安装了DataStax php驱动程序,并按此说明正常工作.

____ upd: 在@Fero的所有说明都没有任何错误之后,命令/usr/local/bin/php -i | grep -A 10 "^cassandra$"向我显示以下内容:

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

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:

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

Aaaaand it's working! I wrote output phpinfo(); in my project and realize that apache using other php version and php.ini, where wasn't extension=cassandra.so at all.

推荐答案

您将需要安装DataStax C/C ++驱动程序,该驱动程序是PHP驱动程序的依赖项.使用这些说明,然后在驱动程序后使用make install已成功构建,将确保构建PHP驱动程序时此依赖项可用.使用PHP驱动程序构建说明您需要确保在运行pecl install cassandra之前,GMP和PHP开发人员库也可用.

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.

由于您使用的是El Capitan,因此遇到了 Homebrew 安装PHP;但是,如果愿意,您也可以使用 MacPorts .

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.

以下是在已安装Xcode和Homebrew的干净OSX El Capitan映像上重现PHP驱动程序安装的步骤:

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 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'

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

You can then verify the installation using the following command:

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

注意:上面使用了PHP v5.5,因为那是El Capitan随附的默认版本;也可以使用PHP v5.6和v7.0.

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.

这篇关于MacOS上的Cassandra php驱动程序-未找到类'Cassandra \ SimpleStatement'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆