the solution is below:
Copy DLLs to Apache bin
Go to your PHP folder, e.g., C:\xampp\php\
Copy these files:
php_pdo_pgsql.dll
php_pgsql.dll
libpq.dll
Paste them into:
C:\xampp\apache\bin
This is the trick that usually fixes Windows XAMPP PostgreSQL issues instantly.
Enable extensions in php.ini
Open C:\xampp\php\php.ini
Make sure these lines exist without semicolons:
extension=pdo_pgsql
extension=pgsql
Save the file.
Restart Apache
In XAMPP Control Panel → Stop Apache → Start Apache
Test
Create test.php in your project folder:
<?php
print_r(PDO::getAvailableDrivers());