Reputation: 11
I'm using Codespaces to develop my project but for some reason I've had a lot of problems to install the pdo_pgsql driver to use Postgress with my symfony project.
Finally, I've found a solution that I've already applied in different codespaces and it works... but I don't understand why it happens and if I'm really doing something wrong.
Here is a little howto of how I install the driver, at what point it gives error, and how I solve it... I hope that we can find out if I did something wrong or that we can help anyone else in my situation:
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install php8.2-pgsql
$ php --ini
extension=pdo_pgsql
$ php -m | grep pdo_pgsql
$ php -i | grep pgsql
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /opt/php/8.2.5/lib/php/extensions/no-debug-non-zts-20220829/pdo_pgsql (/opt/php/8.2.5/lib/php/extensions/no-debug-non-zts-20220829/pdo_pgsql: cannot open shared object file: No such file or directory), /opt/php/8.2.5/lib/php/extensions/no-debug-non-zts-20220829/pdo_pgsql.so (/opt/php/8.2.5/lib/php/extensions/no-debug-non-zts-20220829/pdo_pgsql.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
$ find / -name "pdo_pgsql.so" 2>/dev/null
$ cp /usr/lib/php/20220829/pdo_pgsql.so /opt/php/8.2.5/lib/php/extensions/no-debug-non-zts-20220829/
$ chmod +wx /opt/php/8.2.5/lib/php/extensions/no-debug-non-zts-20220829/*
$ php -m | grep pdo_pgsql
$ php -i | grep pgsql
Upvotes: 1
Views: 6224
Reputation: 46
I had also the same problem, it looks like you just to uncomment the extension pgsql (not the pdo_pgsql extension) and install the pgsql package.
sudo apt-get install php8.2-pgsql
with that you will se the PDO enabled:
with it, I was able to connect to pgsql db and avoid php cli error:
Upvotes: 1