1. Go to this page and download the library: Download nbj/cockroachdb-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nbj / cockroachdb-laravel example snippets
Nbj\Cockroach\CockroachServiceProvider::class
'cockroach' => [
'driver' => 'cockroach',
'host' => env('DB_HOST', 'HOSTNAME-OF-COCKROACH-SERVER'),
'port' => env('DB_PORT', '26257'),
'database' => env('DB_DATABASE', 'DATABASE-NAME'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'DATABASE-NAME',
'sslmode' => 'prefer',
// Only set these keys if you want to run en secure mode
// otherwise you can them out of the configuration array
'sslcert' => env('DB_SSLCERT', 'client.crt'),
'sslkey' => env('DB_SSLKEY', 'client.key'),
'sslrootcert' => env('DB_SSLROOTCERT', 'ca.crt'),
],
use Illuminate\Database\Connection;
use Nbj\Cockroach\CockroachConnector;
use Nbj\Cockroach\CockroachConnection;
use Illuminate\Database\Capsule\Manager as DB;
atabase, $prefix, $config) {
$connection = (new CockroachConnector)->connect($config);
return new CockroachConnection($connection, $database, $prefix, $config);
});
// Create a new DatabaseManager instance
$db = new DB;
// Add a connection using your configuration
$db->addConnection($config);
// Register the DatabaseManager instance as global
$db->setAsGlobal();
$db->bootEloquent();
use Illuminate\Database\Capsule\Manager as DB;
table('users')->get();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.