PHPackages                             m6web/cassandra-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. m6web/cassandra-bundle

AbandonedArchivedSymfony-bundle[Database &amp; ORM](/categories/database)

m6web/cassandra-bundle
======================

Symfony2 bundle on top of datastax/php-driver

v3.0.0(6y ago)30127.4k263MITPHPPHP &gt;=7.1

Since May 25Pushed 5y ago50 watchersCompare

[ Source](https://github.com/BedrockStreaming/CassandraBundle)[ Packagist](https://packagist.org/packages/m6web/cassandra-bundle)[ RSS](/packages/m6web-cassandra-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (21)Used By (3)

CassandraBundle
===============

[](#cassandrabundle)

[![Build Status](https://camo.githubusercontent.com/a78e75835f74ad40f5b24a9e7d7940091cd37893b9130eb167d3e90363cc3e03/68747470733a2f2f7472617669732d63692e6f72672f4d365765622f43617373616e64726142756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/M6Web/CassandraBundle)

The CassandraBundle provide a Cassandra client as a Symfony service.

Installation
------------

[](#installation)

**NOTE :** You need to [install the offical datastax php driver extension](https://github.com/datastax/php-driver)

Use composer:

```
composer require m6web/cassandra-bundle
```

Then make sure the bundle is registered in your application:

```
// config/bundles.php

return [
    \M6Web\Bundle\CassandraBundle\M6WebCassandraBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

Add the `m6web_cassandra` section in your configuration file. Here is the minimal configuration required.

```
m6web_cassandra:
    clients:
        myclient:
            contact_endpoints:
                - 127.0.0.1
                - 127.0.0.2
                - 127.0.0.3

```

Then you can ask container for your client :

```
$cassandra = $this->get('m6web_cassandra.client.myclient');

$prepared = $cassandra->prepare("INSERT INTO test (id, title) VALUES(?, ?)");

$batch     = new Cassandra\BatchStatement(Cassandra::BATCH_LOGGED);
$batch->add($prepared, ['id' => 1, 'title' => 'my title']);
$batch->add($prepared, ['id' => 2, 'title' => 'my title 2']);

$cassandra->execute($batch);

$statement = new Cassandra\SimpleStatement('SELECT * FROM test');
$result = $cassandra->execute($statement);

foreach ($result as $row) {
    // do something with $row
}

$statement = new Cassandra\SimpleStatement('SELECT * FROM test');
$result = $cassandra->executeAsync($statement);

// do something while cassandra query running

foreach($result->get() as $row) {
    // do something with row
}
```

Bundle provide a util class for extracting Datetime from a timeuuid string.

```
use M6Web\Bundle\CassandraBundle\Cassandra\Type as TypeUtils;

$datetime = TypeUtils::getDateTimeFromTimeuuidString('513a5340-6da0-11e5-815e-93ec150e89fd');

if (is_null($datetime)) {
    // something is wrong with supplied uuid
} else {
    echo $datetime->format(\DateTime::W3C); // 2015-10-08 11:38:22+02:00
}
```

DataCollector
-------------

[](#datacollector)

Datacollector is available when the symfony profiler is enabled. The collector allows you to see the following Cassandra data :

- keyspace
- command name
- command arguments
- execution time
- execution options override (consistency, serial consistency, page size and timeout)

**NOTE :** The time reported in the data collector may not be the real execution time in case you use the async calls : `executeAsync` and `prepareAsync`

Configuration reference
-----------------------

[](#configuration-reference)

```
m6web_cassandra:
    dispatch_events: true                 # By default event are triggered on each cassandra command
    clients:
        client_name:
            persistent_sessions: true     # persistent session connection
            keyspace: "mykeyspace"        # default is null, optional keyspace to connect
            load_balancing: "round-robin" # round-robin or dc-aware-round-robin
            dc_options:                   # required if load balancing is set to dc-aware-round-robin
                local_dc_name: "testdc"
                host_per_remote_dc: 3
                remote_dc_for_local_consistency: false
            default_consistency: "one"    # 'one', 'any', 'two', 'three', 'quorum', 'all', 'local_quorum', 'each_quorum', 'serial', 'local_serial', 'local_one'
            default_pagesize: 10000       # ~ to disable pagination
            contact_endpoints:            # required list of ip to contact
                - 127.0.0.1
            contact_whitelist:            # if specified cassandra will connect only to this datacenters/hosts
                dc:
                    - "testdc"
                host:
                    - 172.0.0.1
            contact_blacklist:            # if specified cassandra will not connect to this datacenters/hosts
                dc:
                    - "blacklisted_testdc"
                host:
                    - 6.6.6.6
            port_endpoint: 9042           # cassandra port
            token_aware_routing: true     # Enable or disable token aware routing
            credentials:                  # cassandra authentication
                username: ""              # username for authentication
                password: ""              # password for authentication
            ssl: false                    # set up ssl context
            default_timeout: null         # default is null, must be an integer if set
            timeout:
                connect: 5
                request: 5
            retries:
                sync_requests: 0          # Number of retries for synchronous requests. Default is 0, must be an integer if set

        client_name:
            ...
```

Contributing
------------

[](#contributing)

First of all, thank you for contributing !

Here are few rules to follow for a easier code review before the maintainers accept and merge your request.

- you MUST follow the Symfony2 coding standard : you can use `./bin/coke` to validate
- you MUST run the test
- you MUST write or update tests
- you MUST write or update documentation

Running the test
----------------

[](#running-the-test)

Install the composer dev dependencies

```
$ composer install --dev
```

Then run the test with [atoum](https://github.com/atoum/atoum) unit test framework

```
./bin/atoum
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community33

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor4

4 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~92 days

Recently: every ~199 days

Total

20

Last Release

2254d ago

Major Versions

v1.1.2 → v2.0.02017-04-06

v2.2.4 → v3.0.02020-03-16

PHP version history (3 changes)v1.0.0-betaPHP &gt;=5.5

v2.0.0PHP &gt;=5.6

v2.2.4PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2069361?v=4)[Patrick](/maintainers/Bedrock)[@Bedrock](https://github.com/Bedrock)

---

Top Contributors

[![mojoLyon](https://avatars.githubusercontent.com/u/797786?v=4)](https://github.com/mojoLyon "mojoLyon (12 commits)")[![Oliboy50](https://avatars.githubusercontent.com/u/2571084?v=4)](https://github.com/Oliboy50 "Oliboy50 (5 commits)")[![omansour](https://avatars.githubusercontent.com/u/1131098?v=4)](https://github.com/omansour "omansour (4 commits)")[![mguillermin](https://avatars.githubusercontent.com/u/252093?v=4)](https://github.com/mguillermin "mguillermin (4 commits)")[![fabdsp](https://avatars.githubusercontent.com/u/5878620?v=4)](https://github.com/fabdsp "fabdsp (3 commits)")[![gbouyge](https://avatars.githubusercontent.com/u/5939344?v=4)](https://github.com/gbouyge "gbouyge (3 commits)")[![therpr](https://avatars.githubusercontent.com/u/8452137?v=4)](https://github.com/therpr "therpr (2 commits)")[![NastasiaSaby](https://avatars.githubusercontent.com/u/8245071?v=4)](https://github.com/NastasiaSaby "NastasiaSaby (2 commits)")[![gmillet](https://avatars.githubusercontent.com/u/1568400?v=4)](https://github.com/gmillet "gmillet (2 commits)")[![tijnhendrikson](https://avatars.githubusercontent.com/u/6094214?v=4)](https://github.com/tijnhendrikson "tijnhendrikson (1 commits)")[![GregoireHebert](https://avatars.githubusercontent.com/u/878701?v=4)](https://github.com/GregoireHebert "GregoireHebert (1 commits)")[![jubianchi](https://avatars.githubusercontent.com/u/327237?v=4)](https://github.com/jubianchi "jubianchi (1 commits)")[![kyrylich](https://avatars.githubusercontent.com/u/35771790?v=4)](https://github.com/kyrylich "kyrylich (1 commits)")[![soixante](https://avatars.githubusercontent.com/u/7225568?v=4)](https://github.com/soixante "soixante (1 commits)")[![bblinot](https://avatars.githubusercontent.com/u/68700542?v=4)](https://github.com/bblinot "bblinot (1 commits)")

---

Tags

bundlecassandra

### Embed Badge

![Health badge](/badges/m6web-cassandra-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/m6web-cassandra-bundle/health.svg)](https://phpackages.com/packages/m6web-cassandra-bundle)
```

###  Alternatives

[a2lix/translation-form-bundle

Translate your doctrine objects easily with some helpers

3376.9M38](/packages/a2lix-translation-form-bundle)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[prezent/doctrine-translatable-bundle

Integrate the doctrine-translatable extension in Symfony

14698.4k5](/packages/prezent-doctrine-translatable-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
