Here is the error message:
Fatal error: Call to undefined function pg_escape_string() in ...
I have installed php, postgresql and pdo_pgsql all through homebrew
> php -v
PHP 5.5.30 (cli) (built: Oct 3 2015 23:48:03)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
> postgres --version
postgres (PostgreSQL) 9.4.5
> sw_vers
ProductName: Mac OS X
ProductVersion: 10.11.1
BuildVersion: 15B42
> php -i
pdo_pgsql
PDO Driver for PostgreSQL => enabled
PostgreSQL(libpq) Version => 9.4.4
Module version => 1.0.2
Other functions for working with postgre in php are working fine (connect, query,...)