YAML 异常:Yaml 无效:扫描下一个标记时发现字符“\t”无法在“<reader>”中启动任何标记

YAML exception: Invalid Yaml: while scanning for the next token found character '\t' that cannot start any token in "<reader>"

我正在尝试将我的 Laravel 项目上传到 elastic beanstalk。我在服务器上添加了 MySQL。

我创建了一个 .ebextensions/init.config:

container_commands:
    01initdb: 
        command: "php artisan migrate"
    02initdb
        command: "php artisan db:seed"

现在,我收到此错误:

Unable to deploy application version: The configuration file .ebextensions/init.config in application version cbt-source-10 contains invalid YAML or JSON. YAML exception: Invalid Yaml: while scanning for the next token found character '\t' that cannot start any token in "", line 2, column 1: 01initdb: ^ , JSON exception: Invalid JSON: Unexpected character (c) at position 0.. Update the configuration file.

为了更多参考,我还添加了这些东西:

database.php

define('RDS_HOSTNAME', $_SERVER['RDS_HOSTNAME']);
define('RDS_USERNAME', $_SERVER['RDS_USERNAME']);
define('RDS_PASSWORD', $_SERVER['RDS_PASSWORD']);
define('RDS_DB_NAME', $_SERVER['RDS_DB_NAME']);
//in connections array
'mysql' => [
    'driver' => 'mysql',
    'url' => env('DATABASE_URL'),
    'host' => RDS_HOSTNAME,
    'port' => env('DB_PORT', '3306'),
    'database' => RDS_DB_NAME,
    'username' => RDS_USERNAME,
    'password' => RDS_PASSWORD,
    'unix_socket' => env('DB_SOCKET', ''),
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'prefix' => '',
    'prefix_indexes' => true,
    'strict' => true,
    'engine' => null,
    'options' => extension_loaded('pdo_mysql') ? array_filter([
        PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
    ]) : [],
],

AppServiceProvider.php

public function register()
{
   Schema::defaultStringLength(191);
}

我也运行命令zip -d nameofyourzipfile.zip __MACOSX/\*

我知道我可能只是通过 SSH 连接到 elastic beanstalk 以及一些如何 运行 在项目部署后使用 artisan 命令,但目前我只是想学习 elastic beanstalk。 运行宁命令我可能好多了,b

错误消息 "Invalid Yaml" 在这里有所帮助。从外观上看,您在 02initdb

之后缺少一个冒号

所以 YAML 应该看起来像

container_commands:
  01initdb: 
    command: "php artisan migrate"
  02initdb:
    command: "php artisan db:seed"

希望对您有所帮助!

错误消息是因为您的配置文件中必须有制表符将其转换为空格。