/usr/portage

Build queries for Lucene/Solr indexes in PHP 2

We use Solr a lot at InterNations. Beside usual full text searches, we use it every time we need to receive documents nearly free of charge. It is fast, it is stable and, after some wrestling, our data import works very well as well.

For more than a year we added more and more functionality to a component for building Solr/Lucene queries programmatically. We provide two different ways to create queries: for complex queries we use an expression builder, for simpler ones we have a string based class. A huge advantage of a programmatic API is security: while Lucene’s query language is read-only and therefore non-destructive, query injections can lead to serious data breaches, which both components help to avoid by escaping input strings.

We now feel they are mature and stable enough to be released to the public: say hello to internations/solr-query-component.

Filed on 23-03-2013, 21:09 under , , , , & two comments & no trackbacks

eZ components - doing things fast and smart 0

If you use PHP for some years, you will often fight the same problems, which leads to a lot of unuseful work when implementing basic issues like a properly designed class to send mails in a sane way, parsing an INI-file, basic generating of PHP-code, logging to a file or database or an implementation for a persistant object. This components are often needed and you have to write them by yourself, if you want to work around the tranditional and outdated PEAR-packages. So, maybe some day, you have all the patterns you need and can begin to write code but how long does it take? Two years? For years? Not that sensible. So it raises productivity if you can use a set of components which are small, independent and designed for the current state of the language, means: PHP 5.1.x. eZ components by eZ systems fit this specification. You can solve the problems above and much more – analysing and modifying images, debugging, working with user input and, as surplus, you can work with PHP for shell-scripts with ConsoleTools.
As theory is supposed to be useless without practice, a small example for reading an INI-file. Let’s assume the following INI-file:

[context]
foobar = Bla
bla = blubb
whatever = bar

Now the PHP-code with ezConfigurationIniReader:
$reader = new ezcConfigurationIniReader();
$reader->init('/path/to/your/config/dir, 'config' );
$config = $reader->load();
echo $config->getSetting( "context", "foobar" );

Isn’t that simple?

Filed on 03-05-2006, 11:11 under , , , , , , , & no comments & no trackbacks