我在Laravel 5.4中配置我的postgresql驅動程序以部署到Heroku。這裏是我的config/database.php中,該default
已設置爲pgsql
heroku部署中的非法字符串偏移
'pgsql' => [
'driver' => 'pgsql',
'host' => parse_url(getenv("DATABASE_URL"))['host'],
'database' => substr(parse_url(getenv("DATABASE_URL"))['path'], 1),
'username' => parse_url(getenv("DATABASE_URL")['username']),
'password' => parse_url(getenv("DATABASE_URL")['password']),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
當我承諾我看到這個警告
PHP Warning: Illegal string offset 'username' in app/config/database.php on line 62
當運行heroku run php artisan serve
我得到一個錯誤
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: PDO::__construct() expects parameter 2 to be string, array given
這是我的.env
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=forge
DB_USERNAME=postgres
DB_PASSWORD=