Larry Ullman

Translating Geek Into English

Integrating Zend_Lucene with Yii

I’m just not a big fan of using the Zend Framework as my Web development tool, but one of the framework’s nicest features is that you can use only the parts of it you need. I am, however, a big fan of the Yii framework and one of its many plusses is that you can easily integrate other frameworks and tools into it. Like, for example, the Zend Framework. Yii does not have its own search engine functionality, and Apache’s Lucene is arguably the gold standard (although clearly not the only choice), so tapping into Zend’s Lucene module for a Yii-driven site makes a lot of sense. In this post, I’ll walk you through the steps for integrating  Zend_Lucene into Yii. This post does assume familiarity with PHP, MVC, and Yii.

Designing Databases

A few months back I came across a resource for designing databases (it was posted in a MySQL discussion list). Database Answers has tons of sample designs (a.k.a., models) for various situations. What the site lacks in attractive design in more than makes up for in its usefulness. There are hundreds of designs for you to consider, covering everything from “dog whisperer” to event reservations to online banking. Definitely worth looking at when you’re thinking about the database scheme for your next project.

Configuring FCKEditor for Yii-Driven Sites

I’ve created three Yii-driven PHP sites in the past few months, each of which required an administrative area to dynamically manage the site’s content. Much of the content can contain some HTML, including media (images, videos, etc.), typography, lists, and so forth. So that non-technical people can create nice-looking HTML, I use a Web-based WYSIWYG editor like FCKEditor or TinyMCE. Getting either to work within the Yii environment isn’t too hard, once you know what to do. But because assembling the disparate parts can be tricky, I outline the specific steps and requirements in this post. Note that the post does assume familiarity with Yii.

Programming Notation

I’ve written 17 books now, counting the various editions, and with every chapter of every book there are decisions to be made about what to discuss and what not to. In a way, publishing becomes an endorsement, although I’m really not an endorsement kind of person. Which is to say that it’s never my intention to sell people on things and I don’t believe that my way is the only way let alone the best way to do something. This may all sound odd, but it’s the approach I have, for better or for worse. (And, truth be told, there are still many times when I feel strongly that X is the way to do something and Y isn’t.) Really, what I feel my job as a writer is, is to take all the information I come across, from reading other sources, from listening to the experts, and from my own experiences, and synthesize it all into a coherent bundle of knowledge. Then, of course, convey that knowledge in an easy-to-follow manner. Anyway, my point in this forward is that there are many things that I haven’t written about and that I don’t personally do but that may be worth other people’s consideration. One such practice is the use of Hungarian notation in programming.

Improving MySQL Performance

The performance of any Web application is greatly impacted by how well the database application is being used (if being used, of course). The four biggest impacts on performance are:

  • The storage engine(s) used
  • How columns are defined
  • The existence of proper indexes
  • How queries are written and executed

MySQL supports many different storage engines, each with its own strengths and weaknesses. Which you choose isn’t just a performance issue, it’s also one of features, like whether you need to support FULLTEXT searches (and therefore MyISAM tables) or transactions (which means InnoDB). Sometimes you can get away with using HEAP tables, which exist only in memory. There’s no permanent storage with HEAP tables, but the performance can’t be beat.

For the column definitions, the first goal is to use the smallest possible size for each column. This will be a limitation in your application, so the column’s size still needs to meet or exceed the largest possible value to be stored, but, generally speaking, the more data you want to possibly store, the more space will be required for all the data stored. You should also avoid allowing NULL values in columns. This is a factor in both good database design and in performance optimization.

The DooPHP Framework

I’ve been writing a lot about the Yii framework for Web development using PHP. I’m a big fan of it and expect I’ll be using it for some time to come. I recently came across DooPHP, which I think is also worth consideration (although I haven’t yet used it myself). Besides having a really sharp Web site, some of the strengths of DooPHP seem to be:

  • GUI tools for auto-generating code
  • Many types of caches for improved performance
  • support for replicated databases (great for demanding sites)
  • REST support

I don’t plan on changing frameworks for a while, as I’m quite pleased with Yii, but if you’re looking for a new PHP framework, you may want to consider DooPHP as well.