Captured Moments » Eventually interesting stuff about Linux, Programming, Software, Photography.

Tags

  Work     Gimp         Programming     Bibble     F-Spot     Qt     Web     Weather     Sony     Panorama     Linux     PHP     C++     GPS     Plugin     Hugin     Nikon     Windows     Photoblog     UFRaw     Ubuntu     Software     Live     Usability     Photography  

My Flickr Photos

Books on blurb.com

aus der ev. Kirche Sulzbach (Ts.)
Julia und Paul
Wellner Bou

Admin area

As I want to reduce my webhosting and server accounts, I need a kind of gallery software written in PHP for my photos to replace Gallery2. I don’t like Gallery2, and it is big, needs a lot of memory and is damn slow. I collected some requirements I have (no hierarchical storage but tag/keyword based, fast, PHP, themable, no MySQL required, SQLite or flat file based, searchable, …) and I did not find any PHP gallery out there matching those. (If you have an idea, please tell me!)

on-design-patterns.jpgDesigning a flexible System:
Our one-eyed cat on
Head First’s Design Patterns

So I started to write a generic system (second try, I have some nice ideas but the implementation lacks of some concrete content, a nice overhead, little more at the moment) to built a gallery on top of. And, what I did, too, was looking for existing PHP frameworks which could help me. There is a huge list of usable MVC frameworks on Wikipedia.

I had a look at some of them and chose two of them. I took an existing bigger web project I created years ago which is built on a chaotical system (beginner’s mistakes…) and started to port this to:

  • Yii
  • Zend Framwork
  • A tiny self made system built out of only few classes and interfaces

I spent some time doing this as you can imagine, going through the tutorials, creating the sample applications and applying the same steps to the mentioned project. It came out that I need more or less the same time. Including the time I need to write the own “system”. And finally I decided to built my own tiny system. And I have reasons for this.

The Yii Framework is quite nice. I got a working demo quickly and was able to port the existing layout to it. The Active Record approach is quite nice. But once you have created all the CRUD (create, read, update and delete) files (using the command line tool), all the modifications and adjustments I wanted to do just to display content or evaluate a form without direct relation to a specific database content you need to write the same amount of code you would need without this framework. And I wanted something which makes it easier for me.

Zend Framework has the advantage that it has a huge library of classes for every’s sake use cases. And (if you adjust your autoloader function) you can use parts of the framework, too. But there is no Active Record or similar functionality and I did not want to write all database classes myself. I am doing this for the more complex objects, but for the simple ones, a generic data container with __get and __set is enough. Furthermore the Zend is slow in comparison to a more simple system.

In addition to those reasons, you save the time to dive into those frameworks which can be used to write your own one. What will need a bit more time is to write the full functional form validation. To workaround this it would be possible to use only Zend_Form. But even in this case, I decided to write my own one, rewriting a form library I created a few years ago. It is possible to make it simple and satisfy 90% of your needs. Of course, you risk introducing more bugs, so the decision to write your own system may fire back.

My approach for a generic content system is quite simple: “Everything is an Item“. So I started to create a kind of ItemLib. There are several kind of Items, which may associated to several kind of Views (template engine powered views, views just including a php or html file, views containing text, …). An Item can contain other Items. And there are special kind of Items, ItemCollections implementing an Iterator interface. Itemcollections may contain a collection of Items of the same type but at the same time they implement the generic Item interface, too. It was stunning easy to get a whole, super flexible system with only a few classes of code. I hope I’ll find the time to continue development and maintenance to publish this one day.

    Add comment

    Fill out the form below to add your own comments

    User data





    Add your comment