Programming in Akelos

For some while I have been using the Akelos library for MVC development within PHP. The reason I like this library over other well-known libraries like Zend Framework, CakePHP etc, is that this library is very much coded with “Convension over configuration” which means that you don’t have to over-configure everything. And it’s easy to learn new people how to use it.

For example, when you create a database, you fill inn the fields you like, in a ‘installer’. Each time you need to add fields, you add new up() revisions in the installer, so versioning systems like SVN or git can see that “in revision x, a new fields was added to the sql table”. This means that the versioning system can keep track of the database as well as the files.

Something I also love about Akelos is the ease of translation. In the Views you can write so called “sintags”. Which is basically the template language in Akelos. To write out the contents of a variable, you write {variable name} if you write text that needs translating, you write _{translate this text}. Thats variables and simple translations. Then you have functions, like a form:

<%= form_tag :id => 'myid' %>
<%= text_field 'blog', 'name', :class => 'myclass' %>
</form>

Now I wanted to be able to translate inside function tags, so I made a little adjustment to the Akelos source which made it possible to do:

 <%= link_to _'translated text', :action => 'about' %>
    or
 <%= something 'name', :vals => { 'plain text', _'translated text', _'translated text with %variable' } %>

Here you also see that translated text also can contain variables from the view scope, which is pretty nifty in regards to dynamic translating. This “adjustment” was added to trunk in October 2009.

Posted January 24th, 2010 in hobby, php.

Leave a response: