Postgres with Laravel/PHP

I created a postgres database on Fly.io and I was able to connect to it using the proxy command to connect to it. Using Laravel, I was also able to run my migrations from my local machine while connected to the proxy. I also was able to attach the database to my app. All is good. However, when I deploy my app and I try to connect to the database I get a PDOException could not find driver error.

Hey there!

That sounds like the php pgsql package is missing.

A thing to try is to install the php pdo pgsql package.

Thats a change to your Dockerfile similar to this change: Ensure Swoole is installed for current PHP version by fideloper · Pull Request #1168 · superfly/flyctl · GitHub

The package to add will be phpVERSION-pgsql (grab the exact formula for that package name from the link above).

Thanks Chris! I’m surprised this isn’t in the docs to be able to work with Postgres but I will give it a try.

BTW, I remember you from your fantastic Forge videos from way back. I didn’t know you were at Fly now.

Hi!

Yep, that’s definitely a mistake, I’ll get that into our Dockerfile so it’s smoother for everyone.

Yep, I started just a few months ago! :tada:

Let me know if you hit any issues installing that.

It’s working now, thank you Chris!