Wednesday, May 12

Downgrading php in lucid

Currently I work with CodeIgniter 1.7.1 and one of the biggest issues with this release is the usage of deprecated functions in PHP 5.3, so it's imperative to downgrade the PHP version.
There are several methods, the most straightforward one is described in trk's weblog

The idea is to duplicate the repositories from lucid with the ones from karmic
$ sed s/lucid/karmic/g /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/karmic.list

Now we need to create a preference file where we'll add every file we need from PHP and set them to be installed from the karmic repository

$ gksudo gedit /etc/apt/preferences.d/php
Package: php5
Pin: release a=karmic
Pin-Priority: 991

Package: php5-dev
Pin: release a=karmic
Pin-Priority: 991

Package: php5-curl
Pin: release a=karmic
Pin-Priority: 991

Package: php5-gd
Pin: release a=karmic
Pin-Priority: 991

Package: php5-xdebug
Pin: release a=karmic
Pin-Priority: 991

Package: php-pear
Pin: release a=karmic
Pin-Priority: 991

Package: php5-cli
Pin: release a=karmic
Pin-Priority: 991

Package: php5-common
Pin: release a=karmic
Pin-Priority: 991

Package: libapache2-mod-php5
Pin: release a=karmic
Pin-Priority: 991

Package: php5-mysql
Pin: release a=karmic
Pin-Priority: 991

Now all we need is to "reinstall" the packages

$ sudo apt-get update && sudo apt-get install php5 php5-dev php5-curl php5-gd php5-xdebug php5-cli php-pear php5-mysql

And that's it, we have php 5.2 in lucid

Tuesday, May 11

Why we should use phpdoc with netbeans

It's said that a good developer learns something about his IDE every day, today I start coding again after a long pause doing management and a feature of netbeans greatly surprised me.

When using object oriented programming in PHP is easy to loose track of the type of object we're handling, plus the code completion of IDEs is very poor because of the polyphormic features in PHP.

Here enters a good documentation, I always ask every developer I work with to write phpdoc in any function they made, now another feature of netbeans make it more important, the pseudo class completion makes the IDE know what type of object is returning a function, allowing a fully working autocomplete even in funciton chains.

Good documentation plus good IDE equals great productivity.