Featured, PHP

Three things I love about Lithium

Lithium, the most RAD PHP framework, is slowly grinding towards a 1.0 release, so I figured I wanted to highlight three things I really like about the framework.

1. Clutter free

I believe a framework — or any tool — should assist you without getting in your way, and I think many frameworks fail at this step. I want a framework to help me organise my code and write less code, and if you look at the following Lithium controller code you can see there is hardly any crud code at all:

Whats awesome is that you can now reach /foo/bar.html and /foo/bar.json and it just works. This magic happens because the response assembling by default happens later. You can add support for other file types as well which can be negated by the URL file ending or headers. For example

2. Filters

The most powerful feature of Lithium is its Aspect Oriented Programming capabilities for solving cross-cutting concerns, as AOP is intended for. Lots of Lithium core methods are filterable, and you can write your own methods so that they become filterable. Look at this filter for Model::save:

Its easy to see how this can be used to solve a number of things quite easily; You could apply an application wide caching without touching zilch existing code, and you can reuse that code across applications! You could add default fields (created, modified) once and for all, without a base class.

3. Consistent

This is a damn solid proof of damn solid design; Most methods in Lithium has a consistent signature, making your fluency drastically better as you get better:

As you can see argument numbers are kept really low, almost all methods in the codebase has 1-3 arguments, and the last argument is almost always an options array. Some dont like option arrays due to IDE autocompletion, but personally I absolutely love the method signatures.

So, do you agree that this looks pretty rad? Go check out some more:

Lithium PHP framework

About Raymond Julin

Lead developer at Keyteq Labs, a product business in Bergen, Norway with a reputation for modern user friendly solutions.


  1. Xander

    Hey, looks like some of this post is missing—like all the code examples?

    • Xander

      Ahhh—there they are! :-P Move along, nothing to see… well everything to see actually!

Leave a Reply to Xander Cancel reply