Ideas, opinions and info

ZF Modular admin routes


This guide will show you how to add a modular strucutre in Zend framework with admin routes, and seperate admin controllers in every module.

Url's will look like:



Controllers will be seperated:



By default Zend Framework does not have any built in option to seperate an application by back and frontend like for example CakePHP has. But it is very easy to add this functionality with some custom routes and a frontcontroller plugin. read more

Flexible zend auth adapter


I have been working some more with Zend Framework at work and I needed the Zend_Auth to login users the Zend_Auth_Adapter_Db_Table seems obvious to use only is not very flexible, you cannot use any extra columns in your table to authenticate users.

My solution was to write a Zend_Auth_Db_Select adapter to authenticate against a Zend_Db_Select object so you can write your own query to validate against.

I have also added a way to remember the user and by default only use a session. It did not seem clear from the manual, but Zend_Auth will remember users with a cookie by default. read more

Gearman php extension on ubuntu


Gearman is a really cool job queue to deal with processes that are too heavy to be done on only one server. By default the php extension for Gearman will not compile on Ubuntu 10.10 here is how to get it working. read more

Automatic subdirs as subdomains


Most of us are using virtual hosts in our development environments, mostly the workflow goes like copy virtual host, edit the names, enable the site, reload apache, edit hosts file..

Now there is a shortcut to this :) where you just add your subdirectory and go to your url. 

This guide is written for Ubuntu 10.10 the files can be different a little with other flavors or Macs.

read more

Limited html in comments


Today I made a small change to the comment functionality, so it will be easier to leave snippets of codes. I never really liked BB Code or Markdown syntax so now I allow certain html tags with htmlpurifier.

All non allowed html tags will be stripped if they are not posted in a pre tag ;)

read more

Yii slug behavior


Make your url's look pretty, for search engine's and human's :) 


How to use

Just extract the file and drop it in your components directory. I always keep my behaviors seperate but this depends on your structure.

You will need to have two fields in your table, one with the title or name and the second one where you store the slug make this a varchar.

Now add the behavior in your model, rename the title and slug column to the fields in your database


 * Model behaviors
 * @return array
public function behaviors() {
	return array(
		'SlugBehavior' => array(
			'class' => 'SlugBehavior',
			'slug_col' => 'slug',
			'title_col' => 'title',
			'overwrite' => false,


Now if you save the model the slug will be saved automatically.

*It should now work with high utf 8 ranges too like asian characters but I haven't tested all of them. Let me know if you find any issues.

Yii image helper


There are several image components already for Yii probably the most popular is the Kohana port one of the limitations this component has is that it cannot save thumbnails with adaptive resizing.

I have written a small helper class for PHPThumb the library included has a changed filename for Yii's autoloading.


The helper will allow for automatic caching of thumbnails, just make sure the directory is writeable, the thumb name is based on resize option and width / height and will be saved under a .tmb directory.

Simple example

This will create a thumbnail with adaptive resize width and height will be as specified and cropped from center.

<?php echo ImageHelper::thumb(600,800,'/upload/image.jpg');?>

Advanced example

This changes the resize method so the image will not be cropped enhances the quality settings for jpeg.


<?php echo Yii::app()->request->baseUrl.ImageHelper::thumb(600,800,$img, array(
	'method' => 'resize', 
	'quality' => 90));

With the 3rd parameter you can set any PHP Thumb setting look in the documentation for further information.


Yii tag it widget


You can use this widget for tag forms it features autocomplete and and easy way to delete added tags. I use it in combination with the excellent Taggable behavior


Tag it screenshot

Tag it form

read more

Hello world!


After too long I made a new personal website again. I will post all my interesting findings, technical posts and my idea's and visions on here.

I build my new site on the excellent Yii framework, which is quite an improvement over CakePHP which I mostly used before.

I have added some images from the backend, it features a custom RBAC system based on routes, a blog module and a media model to handle all files.

read more

Displaying 1-9 of 9 result(s).