Skip to content

Can't backup an application that uses read and write database hosts #30

@olimorris

Description

@olimorris

In my database.php file, my config/database.php file has the following connection specified:

        'mysql'   => [
            'read'      => [
                'host'  => env('DB_HOST_READ') . (('homestead' == env('DB_USERNAME') && 'homestead' != gethostname()) ? ':33060' : '')
            ],
            'write'     => [
                'host'  => env('DB_HOST_WRITE') . (('homestead' == env('DB_USERNAME') && 'homestead' != gethostname()) ? ':33060' : '')
            ],
            'driver'    => 'mysql',
            'database'  => env('DB_DATABASE'),
            'username'  => env('DB_USERNAME'),
            'password'  => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

and this results in the following error:

  [Exception]
  Whoops, Undefined index: host

When I change my config/database.php file to:

        'mysql'   => [
            'driver'    => 'mysql',
            'database'  => env('DB_DATABASE'),
            'host'      => env('DB_HOST') . (('homestead' == env('DB_USERNAME') && 'homestead' != gethostname()) ? ':33060' : ''),
            'username'  => env('DB_USERNAME'),
            'password'  => env('DB_PASSWORD'),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
        ],

...it works like a charm. Just something to be aware of.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions