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

Artisan db command fails when using read/write hosts #44383

Closed
necrogami opened this issue Sep 29, 2022 · 3 comments · Fixed by #44394
Closed

Artisan db command fails when using read/write hosts #44383

necrogami opened this issue Sep 29, 2022 · 3 comments · Fixed by #44394
Assignees
Labels

Comments

@necrogami
Copy link

  • Laravel Version: 9.32.0
  • PHP Version: 8.1.10
  • Database Driver & Version: mysqlnd

Description:

When executing the php artisan db console command while having read and write hosts setup in config/database.php it returns this error:

╰─ff php artisan db

   ErrorException

  Undefined array key "host"

  at vendor/laravel/framework/src/Illuminate/Database/Console/DbCommand.php:141
    137▕      */
    138▕     protected function getMysqlArguments(array $connection)
    139▕     {
    140▕         return array_merge([
  ➜ 141▕             '--host='.$connection['host'],
    142▕             '--port='.$connection['port'],
    143▕             '--user='.$connection['username'],
    144▕         ], $this->getOptionalArguments([
    145▕             'password' => '--password='.$connection['password'],

      +16 vendor frames
  17  artisan:37
      Illuminate\Foundation\Console\Kernel::handle()

Steps To Reproduce:

  1. Setup mysql to use read and write hosts
  2. execute php artisan db
@necrogami
Copy link
Author

I understand that i can select --read or --write but it should throw a warning or a better error in my opinion if there's no default host and only using read/write as exampled here: https://laravel.com/docs/9.x/database#read-and-write-connections

@necrogami
Copy link
Author

Or select read by default

@driesvints
Copy link
Member

Thanks. We added a more descriptive message for this.

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

Successfully merging a pull request may close this issue.

4 participants