我使用Elastic Beanstalk将项目部署到AWS EC2实例。部署时,我以this tutorial https://www.youtube.com/watch?v=ISVaMijczKc作为参考。我按照教程中的说明进行了所有操作,但最终出现错误。
数据库主机数组为空。 (SQL:从*中选择*
resource_categories
)
以下是我的代码。
database.php
<?php
define('RDS_HOSTNAME', $_SERVER['RED_HOSTNAME']);
define('RDS_USERNAME', $_SERVER['RED_USERNAME']);
define('RDS_PASSWORD', $_SERVER['RED_PASSWORD']);
define('RDS_DB_NAME', $_SERVER['RED_DB_NAME']);
return [
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
'host' => RDS_HOSTNAME,
'port' => env('DB_PORT', '3306'),
'database' => RDS_DB_NAME,
'username' => RDS_USERNAME,
'password' => RDS_PASSWORD,
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
],
],
'migrations' => 'migrations',
'redis' => [
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'predis'),
],
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_DB', 0),
],
'cache' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
],
];
。ENV] >>
APP_NAME="MyProject"
APP_ENV=development
APP_KEY=base64:FlVBd61BUEzVx6ACa6OOn3Jrp4z+VRpug+F1K1ZeJOs=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myDB
DB_USERNAME=root
DB_PASSWORD=
我使用Elastic Beanstalk将项目部署到AWS EC2实例。部署时,我使用了本教程https://www.youtube.com/watch?v=ISVaMijczKc作为参考。我一直在关注一切...
This is a bug report which might be related to this problem.总而言之,就是如果ConnectionFactory传递了NULL
值,它将(错误地)触发该错误。我怀疑您所有的RDS变量都为空。