singlestoredb-laravel-driver icon indicating copy to clipboard operation
singlestoredb-laravel-driver copied to clipboard

could not find driver

Open IronSinew opened this issue 3 years ago • 12 comments

Just installed the package to test out singlestore on a local docker instance. I have the localhost cluster up and running, but when I changed my env connection to the singlestore driver, I get an error of "could not find driver." Singlestore studio and Tableplus are able to connect to the localhost cluster just fine.

Excited to try it out, but any thoughts? Thanks!

sitenote: I am using docker-compose and the host is correct. My environment variables are accurate.

# php artisan --version
Laravel Framework 9.23.0

.env

DB_CONNECTION=singlestore
DB_HOST=singlestore
DB_PORT=3306
DB_DATABASE=plutus
DB_USERNAME=root
DB_PASSWORD=*****

composer.lock

            "name": "singlestoredb/singlestoredb-laravel",
            "version": "v1.0.0",
            "source": {
                "type": "git",
                "url": "https://github.com/singlestore-labs/singlestoredb-laravel-driver.git",
                "reference": "2dd741545c83301be264d3849ed5018d10a59db0"
            },

IronSinew avatar Aug 06 '22 01:08 IronSinew

Hey @IronSinew, I'm having trouble recreating this. Can you give me any more details on the error you're getting? I just created a new app and was able to connect.

  • Is it a Laravel error?
  • Can you give me a screenshot + trace?
  • Can I see your database.php?
  • PHP Version?

I'm connecting to a cloud instance, which I think is the only difference.

Here's what I've done:

composer create-project laravel/laravel issue16
cd issue16
composer require singlestoredb/singlestoredb-laravel

.env vars:

DB_CONNECTION=singlestore
DB_DATABASE=local_testing
DB_USERNAME=admin
DB_PASSWORD=****
DB_HOST=****

database.php

'singlestore' => [
    'driver' => 'singlestore',
    'url' => env('DATABASE_URL'),
    'host' => env('DB_HOST', '127.0.0.1'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'prefix_indexes' => true,
    'strict' => true,
    'engine' => null,
    'options' => extension_loaded('pdo_mysql') ? array_filter([
        PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
    ]) : [],
],

Then I tinkered the following:

>>> DB::select('select count(*) from events');
=> [
     {#3583
       +"count(*)": 7,
     },
   ]

Hopefully we can run this down!

aarondfrancis avatar Aug 10 '22 13:08 aarondfrancis

It's possible it could this also: https://github.com/singlestore-labs/singlestoredb-laravel-driver/issues/13#issuecomment-1174048233. I'll update the docs to include that reference.

aarondfrancis avatar Aug 10 '22 13:08 aarondfrancis

hey @aarondfrancis, thanks for the reply.

Is it a Laravel error? Yes. This project originated as a Jetstream application and uses Inertia, but I'm not entirely certain that would make much of a difference with the driver set.

Can you give me a screenshot + trace? image

The trace is only of vendor frames, but here ya go.

[2022-08-10 16:12:12] local.ERROR: could not find driver (SQL: select * from `users` where `users`.`deleted_at` is null limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 0): could not find driver (SQL: select * from `users` where `users`.`deleted_at` is null limit 1) at /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php:759)
[stacktrace]
#0 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php(719): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Connection.php(421): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#2 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2630): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#3 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2618): Illuminate\\Database\\Query\\Builder->runSelect()
#4 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(3154): Illuminate\\Database\\Query\\Builder->Illuminate\\Database\\Query\\{closure}()
#5 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2619): Illuminate\\Database\\Query\\Builder->onceWithColumns(Array, Object(Closure))
#6 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(698): Illuminate\\Database\\Query\\Builder->get(Array)
#7 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(682): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#8 /var/www/app/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php(296): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#9 /var/www/app/vendor/spatie/laravel-login-link/src/Http/Controllers/LoginLinkController.php(44): Illuminate\\Database\\Eloquent\\Builder->first()
#10 /var/www/app/vendor/spatie/laravel-login-link/src/Http/Controllers/LoginLinkController.php(18): Spatie\\LoginLink\\Http\\Controllers\\LoginLinkController->getAuthenticatable(Object(Spatie\\LoginLink\\Http\\Requests\\LoginLinkRequest))
#11 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(48): Spatie\\LoginLink\\Http\\Controllers\\LoginLinkController->__invoke(Object(Spatie\\LoginLink\\Http\\Requests\\LoginLinkRequest))
#12 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(261): Illuminate\\Routing\\ControllerDispatcher->dispatch(Object(Illuminate\\Routing\\Route), Object(Spatie\\LoginLink\\Http\\Controllers\\LoginLinkController), '__invoke')
#13 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Route.php(204): Illuminate\\Routing\\Route->runController()
#14 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(725): Illuminate\\Routing\\Route->run()
#15 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))
#16 /var/www/app/vendor/inertiajs/inertia-laravel/src/Middleware.php(88): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#17 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Inertia\\Middleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#18 /var/www/app/vendor/laravel/jetstream/src/Http/Middleware/ShareInertiaData.php(62): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#19 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Laravel\\Jetstream\\Http\\Middleware\\ShareInertiaData->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#20 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(50): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#21 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#22 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(78): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#23 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#24 /var/www/app/vendor/laravel/framework/src/Illuminate/Session/Middleware/AuthenticateSession.php(40): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#25 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\AuthenticateSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#26 /var/www/app/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#27 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#28 /var/www/app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(121): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#29 /var/www/app/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest(Object(Illuminate\\Http\\Request), Object(Illuminate\\Session\\Store), Object(Closure))
#30 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Session\\Middleware\\StartSession->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#31 /var/www/app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#32 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#33 /var/www/app/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#34 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#35 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#36 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(726): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#37 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(703): Illuminate\\Routing\\Router->runRouteWithinStack(Object(Illuminate\\Routing\\Route), Object(Illuminate\\Http\\Request))
#38 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(667): Illuminate\\Routing\\Router->runRoute(Object(Illuminate\\Http\\Request), Object(Illuminate\\Routing\\Route))
#39 /var/www/app/vendor/laravel/framework/src/Illuminate/Routing/Router.php(656): Illuminate\\Routing\\Router->dispatchToRoute(Object(Illuminate\\Http\\Request))
#40 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(167): Illuminate\\Routing\\Router->dispatch(Object(Illuminate\\Http\\Request))
#41 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(141): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}(Object(Illuminate\\Http\\Request))
#42 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#43 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#44 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#45 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#46 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(40): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#47 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#48 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#49 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#50 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(86): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#51 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#52 /var/www/app/vendor/fruitcake/laravel-cors/src/HandleCors.php(38): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#53 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Fruitcake\\Cors\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#54 /var/www/app/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(39): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#55 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Illuminate\\Http\\Middleware\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#56 /var/www/app/vendor/itsgoingd/clockwork/Clockwork/Support/Laravel/ClockworkMiddleware.php(24): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#57 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(180): Clockwork\\Support\\Laravel\\ClockworkMiddleware->handle(Object(Illuminate\\Http\\Request), Object(Closure))
#58 /var/www/app/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
#59 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(142): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
#60 /var/www/app/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#61 /var/www/app/public/index.php(52): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#62 {main}

Can I see your database.php?

<?php

use Illuminate\Support\Str;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    "default" => env("DB_CONNECTION", "mysql"),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    "connections" => [

        "sqlite" => [
            "driver" => "sqlite",
            "url" => env("DATABASE_URL"),
            "database" => env("DB_DATABASE", database_path("database.sqlite")),
            "prefix" => "",
            "foreign_key_constraints" => env("DB_FOREIGN_KEYS", true),
        ],

        "mysql" => [
            "driver" => "mysql",
            "url" => env("DATABASE_URL"),
            "host" => env("DB_HOST", "127.0.0.1"),
            "port" => env("DB_PORT", "3306"),
            "database" => env("DB_DATABASE", "forge"),
            "username" => env("DB_USERNAME", "forge"),
            "password" => env("DB_PASSWORD", ""),
            "unix_socket" => env("DB_SOCKET", ""),
            "charset" => "utf8mb4",
            "collation" => "utf8mb4_unicode_ci",
            "prefix" => "",
            "prefix_indexes" => true,
            "strict" => true,
            "engine" => null,
            "options" => extension_loaded("pdo_mysql") ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env("MYSQL_ATTR_SSL_CA"),
            ]) : [],
        ],

        "lhv2" => [
            "driver" => env("DB_CONNECTION_LHV2"),
            "host" => env("DB_HOST_LHV2"),
            "port" => env("DB_PORT_LHV2"),
            "database" => env("DB_DATABASE_LHV2"),
            "username" => env("DB_USERNAME_LHV2"),
            "password" => env("DB_PASSWORD_LHV2"),
        ],

        "pgsql" => [
            "driver" => "pgsql",
            "url" => env("DATABASE_URL"),
            "host" => env("DB_HOST", "127.0.0.1"),
            "port" => env("DB_PORT", "5432"),
            "database" => env("DB_DATABASE", "forge"),
            "username" => env("DB_USERNAME", "forge"),
            "password" => env("DB_PASSWORD", ""),
            "charset" => "utf8",
            "prefix" => "",
            "prefix_indexes" => true,
            "schema" => "public",
            "sslmode" => "prefer",
        ],

        "singlestore" => [
            "driver" => "singlestore",
            "url" => env("DATABASE_URL"),
            "host" => env("DB_HOST", "127.0.0.1"),
            "port" => env("DB_PORT", "3306"),
            "database" => env("DB_DATABASE", "forge"),
            "username" => env("DB_USERNAME", "forge"),
            "password" => env("DB_PASSWORD", ""),
            "unix_socket" => env("DB_SOCKET", ""),
            "charset" => "utf8mb4",
            "collation" => "utf8mb4_unicode_ci",
            "prefix" => "",
            "prefix_indexes" => true,
            "strict" => true,
            "engine" => null,
            "options" => extension_loaded("pdo_mysql") ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env("MYSQL_ATTR_SSL_CA"),
            ]) : [],
        ],

        "soql" => [
            "driver" => "soql",
            "database" => null,
            "consumerKey" => env("SF_CONSUMER_KEY"),
            "consumerSecret" => env("SF_CONSUMER_SECRET"),
            "loginURL" => env("SF_LOGIN_URL"),
            // Only required for UserPassword authentication:
            "username" => env("SF_USERNAME"),
            // Security token might need to be ammended to password unless IP Address is whitelisted
            "password" => env("SF_PASSWORD"),
        ],

        "sqlsrv" => [
            "driver" => "sqlsrv",
            "url" => env("DATABASE_URL"),
            "host" => env("DB_HOST", "localhost"),
            "port" => env("DB_PORT", "1433"),
            "database" => env("DB_DATABASE", "forge"),
            "username" => env("DB_USERNAME", "forge"),
            "password" => env("DB_PASSWORD", ""),
            "charset" => "utf8",
            "prefix" => "",
            "prefix_indexes" => true,
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven"t actually been run in the database.
    |
    */

    "migrations" => "migrations",

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer body of commands than a typical key-value system
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    "redis" => [

        "client" => env("REDIS_CLIENT", "phpredis"),

        "options" => [
            "cluster" => env("REDIS_CLUSTER", "redis"),
            "prefix" => env("REDIS_PREFIX", Str::slug(env("APP_NAME", "laravel"), "_") . "_database_"),
        ],

        "default" => [
            "url" => env("REDIS_URL"),
            "host" => env("REDIS_HOST", "127.0.0.1"),
            "password" => env("REDIS_PASSWORD", null),
            "port" => env("REDIS_PORT", "6379"),
            "database" => env("REDIS_DB", "0"),
        ],

        "cache" => [
            "url" => env("REDIS_URL"),
            "host" => env("REDIS_HOST", "127.0.0.1"),
            "password" => env("REDIS_PASSWORD", null),
            "port" => env("REDIS_PORT", "6379"),
            "database" => env("REDIS_CACHE_DB", "1"),
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Pagination Defaults
    |--------------------------------------------------------------------------
    |
    | These are global default values for Pagination settings.
    |
    */
    "paginate" => [
        "per_page" => env("PAGINATION_PER_PAGE", 25),
    ],

];

PHP Version? 8.1.5

In my docker-compose.yml file I have the following to attempt to connect to.

  singlestore:
      image: 'memsql/cluster-in-a-box:latest'
      restart: unless-stopped
      environment:
          ROOT_PASSWORD: '${DB_PASSWORD}'
          LICENSE_KEY: '${SS_KEY}'
      # todo: figure out the data mount for persistence
      #      volumes:
      #          - ssmount:/var/lib/postgresql/data
      ports:
          - '127.0.0.1:${FORWARD_SS_DB_PORT:-3306}:3306'
          - '127.0.0.1:${FORWARD_SS_STUDIO_PORT:-8080}:8080'

This is running docker containers in a WSL instance. Are you running this on a mac? I know that my devs have some case-sensitivity issues between our environments on occasion. Is it possible that autoloading isn't actually happening in a linux environment? I was able to replicate the issue with a very simple new project as well.

IronSinew avatar Aug 10 '22 16:08 IronSinew

Hmm that all looks reasonable to me. Can you try to add a pointer to the SS pem file and see what that does? https://github.com/singlestore-labs/singlestoredb-laravel-driver/issues/13#issuecomment-1174048233

aarondfrancis avatar Aug 10 '22 16:08 aarondfrancis

@aarondfrancis does this rely on any specific extensions to be installed already? Currently this is a postgres project, so I'm actually wondering if there are certain extensions that may be pre-reqs.

IronSinew avatar Aug 10 '22 17:08 IronSinew

I did add the pem file, but I'm not sure it's made much of a difference. After noticing there was a check of the pdo_mysql extension being loaded in the database config, I added/enabled it and I'm getting this now:

# php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: select * from information_schema.tables where table_schema = plutus and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:759
    755▕         // If an exception occurs when attempting to run a query, we'll format the error
    756▕         // message to include the bindings with SQL, which will make this exception a
    757▕         // lot more helpful to the developer instead of just the database's errors.
    758▕         catch (Exception $e) {
  ➜ 759▕             throw new QueryException(
    760▕                 $query, $this->prepareBindings($bindings), $e
    761▕             );
    762▕         }
    763▕     }

      +36 vendor frames
  37  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

So, getting somewhere.. but it's still not entirely happy.

IronSinew avatar Aug 10 '22 17:08 IronSinew

Oh you know what, try adding START_AFTER_INIT: "Y" to your docker composer yml.

See https://github.com/singlestore-labs/singlestoredb-laravel-driver/blob/main/.github/workflows/tests.yml#L55 for reference

aarondfrancis avatar Aug 10 '22 19:08 aarondfrancis

I added the START_AFTER_INIT: "Y" to the env params in my docker-compose file and it didn't seem to have an effect, even after rebuilding the image.

IronSinew avatar Aug 10 '22 20:08 IronSinew

Do you have a cloud instance you could try connecting to? To isolate it to cloud vs local?

aarondfrancis avatar Aug 10 '22 22:08 aarondfrancis

@aarondfrancis I created a cloud instance and it was able to connect and work just fine, it seems.

# php artisan migrate

   INFO  Preparing database.

  Creating migration table .............................................................................................................. 209ms DONE


   INFO  Running migrations.

  2014_10_12_000000_create_users_table ................................................................................................... 31ms FAIL

   Illuminate\Database\QueryException

  SQLSTATE[HY000]: General error: 1744 Forwarding Error (node-0a49767d-8626-487a-842f-2fc4d6b938f3-master-0.svc-0a49767d-8626-487a-842f-2fc4d6b938f3:3306): The primary key or unique key named: 'users_hash_id_unique' must contain all columns specified in the shard key [...]

I mean, it failed on a unique constraint for the first migration, but it did successfully create the migrations table at least.

What's quite odd is that I can access the singlestore container just fine via Tableplus / SingleStore Studio.

I was able to connect to the singlestore instance from within the php container running laravel, so it's not a networking issue.

# mysql -u root --host=singlestore -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 251
Server version: 5.7.32 MemSQL source distribution (compatible; MySQL Enterprise & MySQL Commercial)

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]>

It is giving a

# php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [2006] MySQL server has gone away (SQL: select * from information_schema.tables where table_schema = plutus and table_name = migrations and table_type = 'BASE TABLE')

error now though..

IronSinew avatar Aug 10 '22 23:08 IronSinew

Ok getting closer. Can you run php artisan migrate --pretend and take the output and run it from either TablePlus or manually and see if you get any errors.

aarondfrancis avatar Aug 10 '22 23:08 aarondfrancis

Unfortunately php artisan migrate --pretend still gives me a "MySQL server has gone away" error.

IronSinew avatar Aug 10 '22 23:08 IronSinew

@aarondfrancis are you not able to replicate this locally with the docker container? Do I need to provide more information for you to do so?

IronSinew avatar Aug 15 '22 15:08 IronSinew

@IronSinew Sorry that this thread ended up idling. A couple next steps:

  1. Try switching to our new alternative to cluster in a box (not heavily advertised yet, but might be relevant here): https://github.com/singlestore-labs/singlestoredb-dev-image
  2. Is there any way you can try to connect from PHP to SingleStore using pdo_mysql directly?

I can try to repro this next week after the long weekend if you are still stuck. Appreciate you sticking with this to figure it out!

carlsverre avatar Sep 02 '22 20:09 carlsverre

@IronSinew I hit this issue locally because I did not have pdo_mysql installed. Can you verify that pdo_mysql shows up in the output of php -m? You can also check the PDO section of phpinfo() to see whether or not PDO knows how to connect to mysql.

Please re-open this issue if it does not resolve your problem. I will also add documentation regarding this to the README.

carlsverre avatar Sep 16 '22 21:09 carlsverre