Articles with tag "php"
Order:   

Fulltext searches with Xapian and PHP

Sometimes MySQL just isn't quick enough. Especially when it comes to fulltext searches. Everything needs to be indexed correctly, and if we're using different fields with different weights for a relevance percentage, things get very complicated quickly. Xapian to the rescue.
Comments: 16     Views: 7357     Rating: 12345



Observer pattern in PHP

I've recently pretty much fell in love with an observer design pattern. You can basically build the whole application on it using awesome power of event driven programming. What exactly is an observer pattern ? All the theory is accessible on Wikipedia. Basically we have an object you want to monitor ( observe ) for any changes. Most of the time this object just fires out events and we want to listen to them. We can have more objects observing one or more other objects so basically this can be M:N relationship. Classic example in database world are triggers. When the table is updated for example the listening trigger is fired. In window applications when the user clicks a button the event is fired and listeners are notified to handle the event. In the following example we have a validator object checking for a valid email address that fires two types of events we would like to listen to. Those types are obviously valid / invalid email address. We also implement two listeners, one for each event type, listening to the validator. The first one would just be some kind of an error logger, logging the invalid inputs and the second one would write the correct email address into database or something.
Comments: 16     Views: 8029     Rating: 12345



Working with RAR, LZF and BZ2 Compression Formats in PHP

When it comes to dealing with different file formats, it's hard to faze PHP. XML documents, PDF files, JPEG images, MP3 media...you name it and, chances are, there's a PHP extension to handle it. And so it is with compression formats like RAR, LZF and Bzip2 - although these archive formats are far less common today than the ubiquitous TAR and ZIP formats, they are still actively used by many applications and projects, and continue to be supported in PHP via PECL extensions.
That's where this article comes in. Over the next few pages, I'll be introducing you to some PHP extensions that allow you to create, view and manipulate compressed files in these formats. Keep reading, and be prepared to be amazed!
Comments: 1185     Views: 261371     Rating: 12345



A caching pattern for models

This is a caching pattern for models using Zend_Cache and the __call magic method. The initial thought behind this is that a model should be able to return calls either uncached or cached, without initializing some cache object every time. It should be easy to switch between the two calls, and the cache should be coming with the model object already.
Comments: 42     Views: 8493     Rating: 12345