websmurf / laravel-cassandra
Cassandra wrapper for Laravel/Lumen
Installs: 2 210
Dependents: 0
Suggesters: 0
Security: 0
Stars: 8
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >=5.5.0
- illuminate/support: 5.*
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-10-29 02:48:55 UTC
README
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);