PHP, Software Development

PHP 7.4 – Enable PostgreSQL Driver

This post shows how to configure PHP 7.4 (or PHP 7.x, in general) php.ini to enable the PostgreSQL driver, which comes in handy when I need to work on a new version of PHP after a very long break (like months).

Why The Need For a New PHP Version?

I am developing this application on Windows using PHP 7.2, Laravel 7, Angular 8, and PostgreSQL in my spare time. Recently, I have not spent much time on the project because of work. As a result, the codes and settings have become outdated due to Angular 10 and the upcoming Laravel 8. I need to upgrade the codes, at least to the latest framework versions. Also, I keep forgetting how to configure PHP to enable the PostgreSQL driver.

Download Latest PHP 7.x zip Distribution

I am not using a LAMP or XAMP. Instead, I use a zip distribution of PHP 7.x. To download the zip distribution, head to and click either the link for Non-Thread Safe or Thread Safe (recommended) distribution. See PHP FAQs.

Then, extract the zip file to some local folder. Next, create a copy of php.ini-development  and rename it to php.ini.

Modify PHP 7.4 php.ini To Enable PostgreSQL Driver

Once we have the php.ini file, we need to modify it. Uncomment the following lines.

At this point, we have enabled the PostgreSQL driver in PHP 7.4. We can now test the database connectivity with Laravel, e.g., running artisan migrate. Assuming we have a PostgreSQL database running locally, we will get the following error without those changes in php.ini.

Before Running PHP 7.4, Configure the PATH Environment

Before we can run any PHP codes from the command-line window, we have to configure the environment variable PATH. We can set it up in the command-line window before running any PHP codes. Consider the following sample command.

I am using C:\Users\karldev\Desktop\dev\apps\php-7.4.10-Win32-vc15-x64 for this post.


Got comments or suggestions? We disabled the comments on this site to fight off spammers, but you can still contact us via our Facebook page!.

You Might Also Like