Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork27
PHP Driver for ScyllaDB/Apache Cassandra
License
he4rt/scylladb-php-driver
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A modern,feature-rich and highly tunable PHP client libraryforScyllaDB andApache Cassandra 3.0+ using exclusively Cassandra's binary protocol.
This is a wrapper around the [ScyllaDB C/C++ Driver].
Binary versions of the driver, available for Linux systems and officialy supported versions of PHP (8.1 and 8.2), can beobtained from GitHub Releases (soon).
You're also can compile the driver by yourself or use Dockerfile with a pre-set environment to run your tests.
- ScyllaDB C/C++ Shard Aware driver implemented
- Support for
duration Session::execute()andSession::executeAsync()now support asimple string for the query CQL and a simple array for the query execution option- Full support for Apache Cassandra 3.0+
- Support for
tinyintandsmallint - Support for
dateandtime - Support foruser-defined function and aggregate metadata
- Support forsecondary index andmaterialized view metadata
- Migration from C to C++
- Removing PHP Build system in favor of CMake
- Upgraded
Cassandra\Cluster\Builderclass to new PHP argument parsing API - Reduce memory usage from
Cassandra\Cluster\Builder - Migrate from Behat to PestPHP
- Migrated from TravisCI to Github Actions.
This driver works exclusively with the Cassandra Query Language v3 (CQL3) andCassandra's native protocol. The current version works with:
- ScyllaDB 4.4.x and 5.x +
- Apache Cassandra versions 3.0+
- PHP 8.1 and 8.2
- 64-bit (x64)
- Thread safe (TS) and non-thread safe (NTS)
- Compilers: GCC 13.0+, Clang 16+ and c++23
- If you're able to fix a bug yourself, you canfork the repositoryandsubmit a pull request with the fix.
- If you're not able to fix a bug yourself,pleaseopen an issue , describe it with the most detailspossible and wait until one of our maintainers join the conversation.
<?php$cluster = Cassandra::cluster()// connects to localhost by default ->build();$keyspace ='system';$session =$cluster->connect($keyspace);// create session, optionally scoped to a keyspace$statement =newCassandra\SimpleStatement(// also supports prepared and batch statements'SELECT keyspace_name, columnfamily_name FROM schema_columnfamilies');$querySent =$session->execute($statement);$result =$querySent->get();// wait for the result, with an optional timeoutforeach ($resultas$row) {// results and rows implement Iterator, Countable and ArrayAccessprintf("The keyspace %s has a table called %s\n",$row['keyspace_name'],$row['columnfamily_name']);}
Before you compile your driver, first check if yourphp andphp-config matches the supported versions. If not,please checkout to the available versions.
sudo update-alternatives --config phpsudo update-alternatives --config php-config
Supported Versions: 8.1 and 8.2.
Next you will learn how to build the driver to:
- Release/Production
- Debug/Development
- Optimized for Production (CAREFUL!!)
!Make sure first you cloned the repository with --recursive flag!
!Make sure you first install LibUV and LibCassandra/LibScyllaDB!
Install LibUV from your package manager. -> Preferred Way
Installing From Source
git clone --depth 1 -b v1.46.0 https://github.com/libuv/libuv.git \&&cd libuv \&& mkdir build \&&cd build \&& cmake -DBUILD_TESTING=OFF -DBUILD_BENCHMARKS=OFF -DLIBUV_BUILD_SHARED=ON CMAKE_C_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE="RelWithInfo" -G Ninja .. \&& ninja install
Installing From Source (Only Way to get the latest version)
# The only difference between libscylladb and libcassandra is the name of the git repository.git clone --depth 1 https://github.com/scylladb/cpp-driver.git scyladb-driver \&&cd scyladb-driver \&& mkdir build \&&cd build \&& cmake -DCASS_CPP_STANDARD=17 -DCASS_BUILD_STATIC=ON -DCASS_BUILD_SHARED=ON -DCASS_USE_STD_ATOMIC=ON -DCASS_USE_TIMERFD=ON -DCASS_USE_LIBSSH2=ON -DCASS_USE_ZLIB=ON CMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC -Wno-error=redundant-move" -DCMAKE_BUILD_TYPE="RelWithInfo" -G Ninja .. \&& ninja install
We provide common setups using CMake Presets. You can use them by passing the preset name to CMake:
- Release
- RelWithInfo
- CI (Used by GitHub Actions)
- Debug
- ReleaseLibCassandra (Release with LibCassandra)
option(ENABLE_SANITIZERS "Enable sanitizers" OFF)option(ENABLE_AVX "Enable AVX" OFF)option(ENABLE_AVX2 "Enable AVX2" OFF)option(ENABLE_LTO "Enable LTO" OFF)set(CPU_TYPE "x86-64-v3" CACHE STRING "For x86_64 = x86-64|x86-64-v2|x86-64-v3|x86-64-v4|native")# PHP Optionsset(CUSTOM_PHP_CONFIG "" CACHE STRING "Custom PHP config path")set(PHP_VERSION_FOR_PHP_CONFIG "8.3" CACHE STRING "PHP version")option(PHP_DEBUG "Debug or Release" ON)option(PHP_THREAD_SAFE "ZTS(zts) or NTS(nts)" OFF)option(LINK_LIBUV_STATIC "Statically link libuv" OFF)option(BUILD_LIBUV_FROM_SRC "Build LibUV from Source" OFF)option(PHP_DRIVER_STATIC "Statically link PHP Driver" OFF)option(USE_LIBCASSANDRA "Use DataStax LibCassandra instead of LibScyllaDB" OFF)This build you can use it for Production purposes.
To build your Driver, you should first download a few dependencies:
apt install -y pipx build-essential ninja-build libssl-dev libgmp-dev zlib1g-dev openssl libpcre3-dev php-dev&& pipx install cmakeAfter that, you can run the build command inside the repository root folder:
phpize./configuremake -j$(nproc)sudo make installRead our contribution policy for a detailed descriptionof the process.
Soon.
© DataStax, Inc.
Licensed under the Apache License, Version 2.0 (the “License”); you may not usethis file except in compliance with the License. You may obtain a copy of theLicense at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributedunder the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES ORCONDITIONS OF ANY KIND, either express or implied. See the License for thespecific language governing permissions and limitations under the License.
About
PHP Driver for ScyllaDB/Apache Cassandra
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- C++54.1%
- PHP27.5%
- C12.2%
- Gherkin3.7%
- CMake1.3%
- Shell0.6%
- Other0.6%