How to install PHP-IMAP extension in Mac

I’ve finally found the solution. Most of it was here:http://www.september28.co.uk/blog/2011/11/24/php-imap-support-in-mac-os-x-lion-without-recompiling-php/

My machine is a late 2011 Macbook Pro with MacOSX 10.7.4, PHP 5.4. installed via these instructions: http://www.hirmet.com/mac-os-x-lion-upgrade-to-php-5-4

Here’s a step-by-step for those with a similar or identical setup:

Download the imap source from this url, focus on the one with the most recent date which doesn’t end in “Z”: ftp://ftp.cac.washington.edu/imap/

Unarchive, go into folder, run the following commands:

$ make osx EXTRACFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"

The above command will throw a bunch of warnings at you, but should complete sucessfully, unlike the command originally suggested in the september28 blog post.

Next, do the following:

$ sudo cp c-client/*.h /usr/local/include/
$ sudo cp c-client/*.c /usr/local/lib/
$ sudo cp c-client/c-client.a /usr/local/lib/libc-client.a

Once this is done, go into the downloaded php source folder if you made a custom upgrade like I did (as per the second link in the answer) and build the imap.so extension for your system. If you didn’t build a custom version, just download the PHP source for the version you have installed, and use that, it doesn’t matter.

$ cd ~/Downloads/Php-5.4.4/ext/imap
$ phpize
$ ./configure --with-imap==/usr/local/imap-2007 --with-kerberos --with-imap-ssl
$ make

Once done, do the following:

$ sudo cp modules/imap.so /usr/lib/php/extensions/no-debug-non-zts-20100525/

…or if your PHP extension folder is different, put that (you can see the location in phpinfo(); )

Restart apache and you should be ready to go.

$ sudo apachectl restart

Exists statement for ZF2

In the next example you´ll see how to use an exists stament and how to use subqueries in ZF2.


$adapter = $this->tableGateway->adapter;
$sql = new Sql($adapter);

$campos = array(
	'fecha_generacion' => 'fecha_generacion',
	'numero_envio' => new Expression('max(numero_envio)')
);

$subSelect = $sql->select();
$subSelect->columns(array('codigo_empresa'));
$subSelect->from(array('b' => 'documento_resumen'))
		->where('b.codigo_empresa = a.codigo_empresa')
		->where('b.tipo_documento = a.tipo_documento')
		->where('b.fecha_generacion = a.fecha_generacion')
		->where('b.codigo_respuesta = \'0\'');

$select = $sql->select()
	->quantifier(\Zend\Db\Sql\Select::QUANTIFIER_DISTINCT)
	->columns($campos)
	->from(array('a' => 'documento_resumen'))
		->where(
			array(
				'a.codigo_empresa' => $codigoEmp,
				'a.tipo_documento' => $tipoDoc,
				'a.codigo_respuesta' => '2'
			)
		);
$select->where->addPredicate(
		new \Zend\Db\Sql\Predicate\Expression(
		  "NOT EXISTS(" . @$subSelect->getSqlString($adapter->getPlatform()) . ")"
		)
	);
$select->group('a.fecha_generacion');

// Run the query
$statement = $sql->prepareStatementForSqlObject($select);
$result = $statement->execute();

return ArrayUtils::iteratorToArray($result);

Error 2325 SUNAT

Para quienes hayan o estén trabajando en integración con documentos electrónicos con SUNAT es muy probable que tengan el siguiente error:

2325      El certificado usado no es el comunicado a SUNAT

Esto es debido a que SUNAT al parecer usa un caché de 1 día entonces si subieron un nuevo certificado y tratan de generar un documento en ese mismo instante obtendran este error.

Para poder usar el certificado subido deben esperar 1 día despues de haber subido el certificado.

Recompile Interbase for Mac

Add interbase.so to MAMP / OSX

get xcode and macports.
install m4 through macports
download php-source corresponding to mamp-version

create symblinks needed
from http://www.ibexpert.net/forum/viewtopic.phpf=13&t=7&start=0&st=0&sk=t&sd=a

# in short:
# (backslash = keep on same row)
cd /usr
sudo  mkdir -p local/firebird/lib

sudo ln -s /Library/Frameworks/Firebird.framework/Firebird \
local/firebird/lib/libfbclient.dylib

sudo ln -s /Library/Frameworks/Firebird.framework/Headers/ \
local/firebird/include

#create .so
sudo su

cd /path-to-php-source/ext/interbase

/Applications/MAMP/bin/php5/bin/phpize

./configure –with-interbase=/usr/local/firebird

make

#install so to mamp-ext.dir
cp modules/interbase.so \
/Applications/MAMP/bin/php5/lib/ \
php/extensions/no-debug-non-zts-20050922

#add to /Applications/MAMP/conf/php5/php.ini
[firebird]
extension = interbase.so
ibase.allow_persistent = “1”
ibase.max_persistent = “-1”
ibase.max_links = “-1”
ibase.default_db = null
ibase.default_user = NULL
ibase.default_password = NULL
ibase.default_charset = NULL
ibase.timestampformat = “%Y-%m-%d %H:%M:%S”
ibase.dateformat = “%Y-%m-%d”
ibase.timeformat = “%H:%M:%S”

#restart mamp – interbase should show in phpinfo
#enjoy!