Zend Framework in Ubuntu 8.04
With the release of Hardy, the Ubuntu repositories now include a package for the Zend Framework, so you can have just one copy of the library on your server that is automatically updated. To install and use this:
sudo apt-get install zend-framework
then add it to the include_path for your app, in a .htaccess file:
php_value include_path '.:/usr/share/php/libzend-framework-php'
you can then require in Zend Framework classes as you need them, or use the Zend autoloader to pull them in automatically when instantiated.
Comments (0)
Ubuntu 8.04 released
Thursday saw the release of Ubuntu 8.04 (codenamed "hardy heron"). Since I had a load of new PC bits arrive yesterday, I had the opportunity to compare installation of both XP and Ubuntu from scratch on the same machine.
The XP installation took about 40 minutes (not including the initial disc format), during which there were a few interruptions where I had to select my country, language, keyboard layout etc. After it was completed, the machine booted into a very low resolution desktop with fairly sluggish graphics performance and no networking.
The Ubuntu installation on the other hand took 10 minutes (including the repartitioning), had fewer interruptions, and afterwards the machine booted into my screen's native resolution, and everything was working out of the box. The only thing I had to install was the non-free Nvidia drivers for my graphics card, which took a few clicks (no CDs or web searching required).
My only complaints about the Ubuntu installation process are the partioning screen, which still uses terminology that would scare off a lot of users. Since it can detect if any other operating systems are installed on the disc, really it should present some simple options like:
- Install Ubuntu on disc XXX, alongside your current Microsoft Windows XP installation
- Install Ubuntu on another disc (if there's more than one in the machine)
- Replace your existing Microsoft Windows XP installation (warning about deleting data)
if the user chooses option 1 they're presented with the slider to control how much space each OS should use (and it should default at giving each 50% of the disc space).
Manual creation of partitions, and terminology like 'contiguous space' and 'swap' should be hidden behind an advanced/manual configuration screen.
Netbeans vs. Eclipse
I'm also considering switching from Eclipse to Netbeans for PHP development. I'm already using Netbeans for Ruby (i.e. Rails) stuff at work, and I've never been especially happy with Eclipse. It's not particularly easy to setup (largely because the Ubuntu respository holds version 3.2 which isn't compatible with the latest version of PDT), and generally the more plugins you seem to add to it, the more flakey it becomes.
Netbeans is certainly much easier to setup - the version from the repository works straight out of the box, and adding plugins is a simple as ticking the ones you want to install from a menu. I believe both apps are Java-based, but Netbeans generally feels more responsive, and there are fewer hangs whilst the app reparses some code.
However, the PHP plugin for Netbeans still seems to be in its infancy. Once installed, I opened a sample PHP file and was presented with a horrible lime green background behind all the code. Apparently this isn't something that can be changed in the preferences yet (!). The code was all shown in a serif font, even though the options had it set to use a monospaced one.
Comments (0)
MySQL - weighting fields in LIKE searches
A client asked us today if we could do some work on their search feature to weight the ordering of results if the search term appeared in the title. The site is running a fairly old version of one of our products which uses a very basic LIKE search (the current version of the same system uses a Lucene-based system). The example search term they gave was a 3-letter word, which pretty much rules out MySQL fulltext (when you start reducing ft_min_word_len fulltext searching gets pretty slow), so we came up with a way of weighting standard LIKE searches:
SELECT title, description, IF(title LIKE '%who%', 3, 0) + IF(description LIKE '%who%', 2, 0) AS weight FROM `products` WHERE fullname LIKE '%who%' OR brief_description LIKE '%who%' ORDER BY weight DESC
What this does is create an arbitary 'weight' value purely based on which field(s) the search term appears in. This value is used to order the products.
Yes, it's slow, as it's doing a two LIKE searches for every field, for every search term. But in this relatively small dataset (~200 products), it still runs in a fraction of a second so it's okay as a temporary solution.
Comments (0)