websmurf / laravel-cassandra by websmurf

Cassandra wrapper for Laravel/Lumen
2,208
8
4
Package Data
Maintainer Username: websmurf
Maintainer Contact: adam@bandhosting.nl (Adam van Dongen)
Package Create Date: 2016-07-27
Package Last Update: 2016-07-29
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-05-03 03:11:35
Package Statistics
Total Downloads: 2,208
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 8
Total Watchers: 4
Total Forks: 1
Total Open Issues: 0

Laravel/Lumen wrapper for Cassandra

Build Status Scrutinizer Code Quality Code Coverage

Installation

This packages uses the cassandra functionality provided by the Datastax php driver. It needs to be installed before you will be able to use this package. See for more information: http://datastax.github.io/php-driver/

Install using composer:

composer require websmurf/laravel-cassandra

After that, register the service provider by adding it in your app.php:

$app->register(Websmurf\LaravelCassandra\CassandraServiceProvider::class);

You can publish the configuration using the following command:

php artisan config:publish websmurf/laravel-cassandra

Or simply create a copy of the config/cassandra.php file in your app/config folder.

After that, change the configuration according to your needs.

Usage

After installation, you can inject Cassandra in your constructor and use it in your code:

// Inject in the constructor
public function __construct(Cassandra $cassandra, Request $request)
{
	$this->cassandra = $cassandra;
}

// Create prepared statement
$prepared = $this->cassandra->prepare('THIS IS MY CQL STATEMENT');

// Create options for execution
$options = new \Cassandra\ExecutionOptions([
	'arguments' => $data,
  	'consistency' => \Cassandra::CONSISTENCY_ONE
]);

// Execute statement
$this->cassandra->execute($prepared, $options);