Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote only not working #5

Open
nick-potts opened this issue Jan 11, 2025 · 16 comments
Open

Remote only not working #5

nick-potts opened this issue Jan 11, 2025 · 16 comments

Comments

@nick-potts
Copy link
Contributor

nick-potts commented Jan 11, 2025

php artisan migrate:fresh --seed

   ErrorException 

  Undefined array key "database"

  at vendor/turso/libsql-laravel/src/LibsqlServiceProvider.php:88
     84▕                             password: $config["password"] ?? '',
     85▕                             options: $config
     86▕                         );
     87▕                     },
  ➜  88▕                     database: $config["database"],
     89▕                     config: $config,
     90▕                 );
     91▕             });
     92▕         });

      +23 vendor frames 

  24  artisan:13
      Illuminate\Foundation\Application::handleCommand(Object(Symfony\Component\Console\Input\ArgvInput))
"libsql" => [
  "driver" => "libsql",
  "url" => env("TURSO_DATABASE_URL"),
  "password" => env("TURSO_AUTH_TOKEN"),
],

with both env variables set

@SadeghPM
Copy link

Yes, same exception in remote db.

@stursby
Copy link

stursby commented Jan 11, 2025

Also getting the same error (Was trying to run php artisan migrate)

image

@nick-potts
Copy link
Contributor Author

nick-potts commented Jan 11, 2025

There's some places where this library/libsql-php just aren't compatible with Laravel, meaning a lot of the base commands like db:wipe, migrate etc don't work. I've opened an issue that should help track it down #6

@levydsa
Copy link
Collaborator

levydsa commented Jan 13, 2025

Remote also doesn't work because of a small bug with the libsql crate. I'll be reporting it and the fix will be available soon.

@darkterminal
Copy link
Contributor

This issue should be fix by the latest release.

@tyrailleverett
Copy link

I have updated to the latest version (^0.1.2), but now I get this error:
Sync is not supported in databases opened in Remote mode. (Connection: libsql, SQL: select exists (select 1 from sqlite_master where name = 'migrations' and type = 'table') as "exists").

Here is how my libsql connection looks:
'libsql' => [
'driver' => 'libsql',
'url' => env('TURSO_DATABASE_URL'),
'password' => env('TURSO_AUTH_TOKEN'),
'database' => null
],

If I remove the database, I still get the error of: Undefined array key "database"

@darkterminal
Copy link
Contributor

@tyrailleverett Try copy-paste this:

'libsql' => [
    'driver' => 'libsql',
    'database' => '',
    'prefix' => '',
    'url' => 'your-turso-database-url',
    'password' => 'yout-turso-auth-token',
],

See this line

And see what happen?

@tyrailleverett
Copy link

@darkterminal I get the same error

Image

Image

@darkterminal
Copy link
Contributor

Did you use Which OS you used? If you used UNIX like Linux/Darwin, try to reload your .env file by source .env and try to check is the connection is correct or not by running php artisan db:show before migrate.

@tyrailleverett
Copy link

I am using an m2 Macbook pro. I first ran source .env as requested. I am still getting the same error as before when I run the php artisan db:show

Image

@darkterminal
Copy link
Contributor

Here my Laravel Setup Configuration for Remote Only Connection:

here my .env file:

DB_CONNECTION=libsql
DB_HOST=libsql://<your-database-url>.turso.io
DB_PASSWORD=<your-auth-token>

at bootstrap/providers.php

<?php

return [
    App\Providers\AppServiceProvider::class,
    Libsql\Laravel\LibsqlServiceProvider::class,
];

at config/database.php

...

'libsql' => [
    'driver' => 'libsql',
    'url' => env('DB_HOST', ''),
    'password' => env('DB_PASSWORD', ''),
    'database' => null,
    'prefix' => '',
    'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
    'busy_timeout' => null,
    'journal_mode' => null,
    'synchronous' => null,
],

...

And here the result of php artisan db:show command:

Image
And here is the result of php artisan migrate command:

Image

@floodx92
Copy link

I get the same Sync is not supported in databases opened in Remote mode. Are you guys testing any of your packages? What is going on with you? Neither one of you PHP packages works, or production ready...

@SadeghPM
Copy link

It seems they haven't run any simple database commands, like migration, before the announcement.

@tyrailleverett
Copy link

The docs did not mention adding Libsql\Laravel\LibsqlServiceProvider::class to the providers.php file, but I did that since you have it here, but I still get the same results. Sync is not supported in databases opened in Remote mode. My settings are exactly like yours that you have displayed here, but my migrations are not working. Im not sure what I am doing wrong if you are able to get your migrations working.

I have done config:clear, cache:clear, all of it. Nothing is working.

@arif98741
Copy link
Contributor

arif98741 commented Jan 22, 2025

database key missing occurred when no database array key is provided in config/database.php for libsql. I just made configuration simple and it's working fine

config/database.php file

'connections' => [

        "libsql" => [
            "driver" => env("DB_CONNECTION", "libsql"),
            "database" => env('DB_PATH','xxxx-yyyzzz.aws-us-east-1.turso.io'),
        ],

.env file

DB_CONNECTION=libsql
DB_PATH=xxxx-yyyzzz.aws-us-east-1.turso.io
#DB_HOST=127.0.0.1
#DB_PORT=3306
#DB_DATABASE=laravel
#DB_USERNAME=root
#DB_PASSWORD=

Terminal Output

Image

@svenluijten
Copy link

It looks like @darkterminal is using the main branch instead of one of the tagged versions (which most other people are using, I assume).

To make it work (for now):

  • Allow dev minimum stability in composer.json by updating the minimum-stability config option to "dev".
  • Run composer update turso/libsql-laravel:dev-main -W to update this package to what's currently in main.
  • php artisan db:show now works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants