【问题标题】:where and how these parameters in laravel are set? `LARAVEL_LOAD_HOST` , `LARAVEL_LOAD_PORT` , `LARAVEL_LOAD_USER`?laravel 中的这些参数在哪里以及如何设置? `LARAVEL_LOAD_HOST`、`LARAVEL_LOAD_PORT`、`LARAVEL_LOAD_USER`?
【发布时间】:2021-10-31 13:56:48
【问题描述】:

尝试使用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 常量作为这些参数的等效值?谁设置了这些参数,何时完成?

感谢任何提示,

【问题讨论】:

    标签: php environment-variables laravel-8


    【解决方案1】:

    快速浏览引擎盖会发现这些键设置在 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'],
        ];
    }
    

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

    【讨论】:

      猜你喜欢
      • 2018-09-04
      • 2017-10-05
      • 1970-01-01
      • 2022-06-11
      • 1970-01-01
      • 2011-11-08
      • 1970-01-01
      • 1970-01-01
      • 2020-09-10
      相关资源
      最近更新 更多