Quick Tech Recipe – Installing the Technical Analysis PHP PECL Extension

For those of you doing technical analysis, Anatoliy Belsky has ported the comprehensive Technical Analysis Library to PHP as a PECL extension. As it is a work in progress, the pecl extension broke during install. Here’s the bug report  that describes the error in more detail : https://bugs.php.net/bug.php?id=63511 . Anatoly has fixed this in the trunk, but a newer, stable release it not out yet.

So until then, here’s a stop-gap measure to get it to work. The examples are specific to Ubuntu, but you’ll get the gist of it and adapt.

  1. Download and extract the pecl extension
    wget http://pecl.php.net/get/trader-0.3.0.tgz;
    tar xzf trader-0.3.0.tgz;
  2. Edit trader-0.3.0/trader.c, and replace “PHP_FE_END” with “{ NULL, NULL, NULL, 0, 0 }” on line 1225.
  3. Now install this PECL extension manually:
    cd trader-0.3.0
    phpize
    ./configure
    make
    make install
  4. Finally, enable the extension in PHP :
    sudo echo "extension=trader.so" > /etc/php5/conf.d/trader.ini
  5. And check
    php -m | grep trader

You’ll need PHP 5.3.15 and above for this to install.

Quick Tech Recipe – Installing Sphinx and the PECL extension

Installing sphinx and the PECL extension has confused me a couple of times. The installation is arcane and buggy, so I’ve written down the steps to automate it. I’ve used this on Ubuntu 11.10+ . If you know of how to make this work on CentOS or another Linux, let me know. And now, the script :

sudo apt-get install g++
wget http://sphinxsearch.com/files/sphinxsearch_2.0.6-release-0ubuntu11~lucid_amd64.deb
sudo dpkg -i sphinxsearch_2.0.6-release-0ubuntu11~lucid_amd64.deb
cd /usr/share/sphinxsearch/api/libsphinxclient
sudo ./configure
sudo make
sudo make install
sudo pecl install sphinx #Press enter when asked for path
sudo touch /etc/php5/conf.d/sphinx.ini
sudo echo "extension=sphinx.so" > /etc/php5/conf.d/sphinx.ini
sudo /etc/init.d/apache2 restart

Hope this saves you some time.