I’m working on a Laravel project where I want to use GridDB as my database. Since Laravel doesn’t have built-in support for GridDB, I’m trying to create a custom database driver to handle the connection, since there’s a connector for PHP in their docs. Here’s what I’ve done so far:
- Created a custom database driver:
'connections' => [ // Other connections...
'griddb' => [
'driver' => 'griddb',
'host' => env('GRIDDB_HOST', '127.0.0.1'),
'port' => env('GRIDDB_PORT', 10001),
'cluster' => env('GRIDDB_CLUSTER', 'myCluster'),
'username' => env('GRIDDB_USERNAME', 'admin'),
'password' => env('GRIDDB_PASSWORD', 'admin'),
],
],
- Created a service provider for it:
class GridDBServiceProvider extends ServiceProvider
{
public function register()
{
$this->app['db']->extend('griddb', function ($config, $name) {
$config['name'] = $name;
return new GridDBConnection($config);
});
}
}
- Added the Connection class:
class GridDBConnection extends Connection
{
protected $gridstore;
public function __construct(array $config)
{
$factory = StoreFactory::getInstance();
$this->gridstore = $factory->getStore([
'notificationMember' => $config['host'] . ':' . $config['port'],
'clusterName' => $config['cluster'],
'user' => $config['username'],
'password' => $config['password'],
]);
parent::__construct($this->gridstore);
}
}
- Added the service provider:
'providers' => [
// providers ..
AppProvidersGridDBServiceProvider::class,
]
So when I try to run migrations I get
unsupported driver [griddb].
Does anyone know what is happening, why is the connector not connecting?