laravel 中的这些参数在哪里以及如何设置? `LARAVEL_LOAD_HOST`、`LARAVEL_LOAD_PORT`、`LARAVEL_LOAD_USER`?

where and how these parameters in laravel are set? `LARAVEL_LOAD_HOST` , `LARAVEL_LOAD_PORT` , `LARAVEL_LOAD_USER`?

尝试使用 php artisan schema:dump 后,出现此错误。

The command "mysqldump   --skip-add-drop-table --skip-add-locks --skip-comments --skip-set-charset --tz-utc --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}" --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" "${:LARAVEL_LOAD_DATABASE}" --routines --result-file="${:LARAVEL_LOAD_PATH}" --no-data" failed.

顺便说一句,主要问题不是如何解决这个问题。但我的问题是这些参数在哪里定义? (LARAVEL_LOAD_HOSTLARAVEL_LOAD_PORTLARAVEL_LOAD_USERLARAVEL_LOAD_PASSWORD 等) 为什么 laravel 不使用 env 常量作为这些参数的等效值?谁设置了这些参数以及何时完成此设置?

感谢任何提示,

快速浏览一下引擎盖会发现这些键是在 vendor\laravel\framework\src\Illuminate\Database\Schema\MySqlSchemaState.php 中设置的(或 SqliteSchemaState.phpPostgressSchemaState.php - 取决于您使用的是什么)。

/**
 * Get the base variables for a dump / load command.
 *
 * @param  array  $config
 * @return array
 */
protected function baseVariables(array $config)
{
    $config['host'] = $config['host'] ?? '';

    return [
        'LARAVEL_LOAD_SOCKET' => $config['unix_socket'] ?? '',
        'LARAVEL_LOAD_HOST' => is_array($config['host']) ? $config['host'][0] : $config['host'],
        'LARAVEL_LOAD_PORT' => $config['port'] ?? '',
        'LARAVEL_LOAD_USER' => $config['username'],
        'LARAVEL_LOAD_PASSWORD' => $config['password'],
        'LARAVEL_LOAD_DATABASE' => $config['database'],
    ];
}

$config 提供给 baseVariables 方法的数组包含来自 config/database.php 的值(用于您的连接)。