My PHP project uses PGSQL. It runs successfully from Homestead on my dev machine. As soon as I add hhvm: true
to my project in homestead.yaml, and provision -- my web app throws a PDOException
with a driver is not found. The exception goes away as I remove the hhvm:true
and re-provision homestead.
Obviously HHVM's config does not include the PGSQL driver.
How do I correct that?
You don't give a lot of details about your setup, so it's not clear if you have the Postgres driver installed. Postgres isn't supported right out of the box. You have to build and/or install it yourself.
Facebook has an "official" list of HHVM extensions. PGSQL is not (yet) integrated into HHVM proper, but Facebook's page points to the external GitHub project, which is here:
Postgres Extension for HHVM
Below is a summary of the project instructions; you can read them yourself in the README.md
files.
If you want to build it from source, you will need the hhvm-dev and libpq-dev packages to be installed. Once they have been installed, the following commands will build the extension:
$ cd /path/to/source
$ hphpize
$ cmake .
$ make
This will produce a pgsql.so file, the dynamically-loadable extension. Copy this file to /etc/hhvm/pgsql.so
.
If you don't want to build it, there are pre-built binary versions for some of the popular distros in the separate "releases" branch here: Releases.
Again, copy the downloaded pgsql.so file to /etc/hhvm/pgsql.so
.
Whether you build from source or install binaries, you need to tell HHVM where to find it. Edit your config file (generally /etc/hhvm/php.ini
) and add these if they're not present:
extension_dir = /etc/hhvm
hhvm.extensions[pgsql] = pgsql.so
You can check that everything is working by running
hhvm --php -r 'var_dump(function_exists("pg_connect"));'
If everything is working fine, this will output bool(true)
.
You may need to restart HHVM to have the server pick up the extension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With