Friday, June 24, 2011

Installing SphinxSearch with libstemmer from FreeBSD ports

Environment: Sphinx 0.9, FreeBSD

Problem:
Sphinx port has libstemmer options commented out in Makefile. With automatic upgrades, it loses stemming for anything except for default EN and RU.

Procedure of rebuilding the port with libstemmer

# (become root)
cd /usr/ports/textproc/sphinxsearch


Create file Makefile.local with this line:
CONFIGURE_ARGS+= --with-libstemmer


make clean
make
fetch http://snowball.tartarus.org/dist/libstemmer_c.tgz
cd work/sphinx-*/
tar zxvf ../../libstemmer_c.tgz
cd ../..
make
make deinstall
make reinstall
make clean

Do not forget to rebuild index if you did not use libstemmer before

Tuesday, June 21, 2011

__autoload and Zend

Environment: PHP 5.3.6, Zend Framework 1.11.6

This problem occurred when I needed to build a mixed environment where the existing code was "pure PHP" and new code was based on Zend Framework.

The "pure PHP" code's __autoload function stopped working as soon as Zend application ran.

Apparently, when there is a call to spl_autoload_register, __autoload is ignored.

The solution was to rename __autoload to OldAutoLoad and call:
spl_autoload_register('OldAutoload');

Note: after that, the OldAutoload was called first and then Zend's autoload. In order to let OldAutoload ignore Zend classes, I replaced require_once calls with @include_once.