英文:
Laravel Controllers not connecting to postgres 'could not find driver'
问题
I am using Laravel 10.10 on Debian 10.2 with Postgres 13.11. php artisan tinker works and I can retrieve data this way, I can even migrate to the database. But I cannot get data through the Controllers.
return view('sales', [
'sales' => Sales::findOrFail(2)
])
results in could not find driver (Connection: pgsql...
I don't think this is a routes issue. When I go to Network and look at the database table connect it says 500 error. I also have sorted my database configuration, since I can migrate. I have also tried numerous remedies that I could find but I've had no success.
This is unique because I can connect to the database through tinker and by running migrations. So I am making a silly mistake somewhere else.
laravel.log output...
[2023-06-14 06:42:42] local.ERROR: could not find driver (Connection: pgsql, SQL: select * from "migrations") {"exception":"[object] (Illuminate\\Database\\QueryException(code: 0): could not find driver (Connection: pgsql, SQL: select * from \"migrations\") at /var/www/html/driptech/vendor/laravel/framework/src/Illuminate/Database/Connection.php:795)
[stacktrace]
英文:
I am using Laravel 10.10 on Debian 10.2 with Postgres 13.11. php artisan tinker works and I can retrieve data this way, I can even migrate to the database. But I cannot get data through the Controllers.
return view('sales', [
'sales' => Sales::findOrFail(2)
]);
results in could not find driver (Connection: pgsql...
I don't think this is a routes issue. When I go to Network and look at the database table connect it say 500 error
. I also have sorted my database configuration, since I can migrate. I have also tried numerous remedies that I could find but I've had no success.
This is unique because I can connect to the database through tinker and by running migrations. So I am making a silly mistake somewhere else.
laravel.log output...
[2023-06-14 06:42:42] local.ERROR: could not find driver (Connection: pgsql, SQL: select * from "migrations") {"exception":"[object] (Illuminate\\Database\\QueryException(code: 0): could not find driver (Connection: pgsql, SQL: select * from \"migrations\") at /var/www/html/driptech/vendor/laravel/framework/src/Illuminate/Database/Connection.php:795)
[stacktrace]
Any assistance would be appreciated.
答案1
得分: 1
通常服务器上会安装两个版本的PHP。一个用于在响应HTTP请求时由Web服务器使用,另一个用于CLI。
有可能您没有为这两个安装都安装或配置PostgreSQL模块吗?
使用phpinfo()
函数和php -i
命令来检查是否已安装并启用了PostgreSQL。
英文:
Typically there are two versions of PHP installed on a server. One is used by the web server when responding to HTTP requests and the other is for the CLI.
Is it possible that you don't have the PostgreSQL module installed or configured for both installations?
Use the phpinfo()
function and php -i
command to check if PostgreSQL is installed and enabled.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论