CakePHP with Postgresql 8.3 and XAMPP 1.7.3 on Windows 7 64bit configuration

I just started using CakePHP 2.1 and wanted to switch to Postgresql as the database. CakePHP can be configured for postgres usage but it did not connect to the database when I switched over to it. I keep receiving the following error on the configuration page:

Cake is NOT able to connect to the database.
Database connection “Postgres” is missing, or could not be created.

After a considerable search I was not able to find a solution.  After taking a week break I finally ran into a post for SQL Server that pointed me in the right direction. The short answer is that the php.ini file for XAMPP needed to be changed to enable the postgres drivers. Additionally, my postgres install is 32 bit on a 64 bit OS. So I had to copy the posgres dll from the postgres bin directory to the apache bin directory. Not pretty but it works.

Here is the details on how to do it.  Once the CakePHP database.php file is changed to postgres I started getting the “Database connection “Postgres” is missing, or could not be created.” error.

public $default = array(
‘datasource’ => ‘Database/Postgres’,
‘persistent’ => true,
‘host’ => ’′,
‘port’ => ’5432′,
‘login’ => ‘postgres’,
‘password’ => ‘mypwd’,
‘database’ => ‘mydb’,
‘schema’ => ‘myschema’,
‘prefix’ => ”,
‘encoding’ => ‘utf8′

The web page error looks like this:

So I pointed to a controller that I created from the tutorial to get more debug information.

That lead me to this post:

I located my php.ini file in C:\xampp\php and change un-commented the following lines:


I bounced apache and got the error message the LIBPG.dll  is missing.  As stated about, the posgresql dll’s are not found in the postgres install because I am running Windows 7 64 bit.  Copy these dll’s from C:\Program Files (x86)\PostgreSQL\8.3\bin to C:\xampp\apache\bin.

comerr32.dll, gssapi32.dll, k5sprt32.dll, krb5_32.dll, libiconv-2.dll, libintl-8.dll, libpq.dll

Bounce apache one more time and CakePHP is now connected to my Postregsql server.

This entry was posted in CakePHP, Software Development. Bookmark the permalink.