I am using
to try and develop in PHP locally before pushing to heroku.
However, I am not able to use Postgres locally because the PDO driver is missing:
How can I install (or enable?) PostgreSQL PDO (pdo_pgsql) on
I could not find anything in the official docs, nor online. (The docs seem to be lacking for PHP and, especially, on how to use heroku locally.)
FYI, running Mac OS X.
If needed, here's the minimal example I'm working with for testing purposes:
* Runs fine on XAMPP, which has PHP Version 5.5.15 with pdo_pgsql installed.
* But won't run on heroku local, which has PHP Version 5.5.34 WITHOUT pdo_pgsql installed.
* `PDOException`, `could not find driver'`
$dbh = new PDO( "pgsql:dbname=test;host=localhost", 'fabien', NULL );
$res = $dbh->query( 'SELECT name FROM test_table' )->fetchAll( PDO::FETCH_ASSOC );
echo $res['name']; // echoes the content of said table, i.e. `hello database` -- OK
I realized my whole model of what
does was totally off. It merely does this:
“Heroku Local reads configuration variables from a .env file.” (from https://devcenter.heroku.com/articles/heroku-local)
I'd wrongly assumed
it provided, locally, the same sort of flexibility heroku provides in the cloud (i.e.: dev-prod-parity
, e.g.: the ability to pick which PHP version to run and reproduce locally the same setup as in the cloud), and that it came with its own binaries.
merely relies on the system's default PHP install and extensions (or lack thereof) for running the web server.
Once understood, the problem became to fix it by installing pdo_pgsql on the local system, as per Shyam Bhimani's solution.