Minifying your Zend Framework views

When your website is getting alot of traffic, you’ll eventually reach the point where you want to tune things (or good habits). Next to backend and frontend caching, checking your expiry headers, optimizing images, … you can also minify your application’s output. Minifying or ‘minification’ is ‘the process of removing all unnecessary characters from source code, without changing its functionality‘.

Now keep in mind, it’s always better to load your CSS from an external stylesheet, this way it can get cached + you can use a very cool tool called http://code.google.com/p/minify/ . This leaves us with all the other code, your website’s HTML.

Using view output filters in Zend, it’s fairly easy to minify all your html/javascript/css output. In this blog post I’ll show you how to get things up and running. We’ll be using the same open source Minify library (http://code.google.com/p/minify/source/browse/#svn%2Ftrunk%2Fmin%2Flib)

Create a new view output helper (more about this):

<?php
require_once 'Zend/Filter/Interface.php';
require_once 'Minify/HTML.php';
require_once 'Minify/CSS.php';
require_once 'JSMin.php';
 
class My_View_Filter_Minify implements Zend_Filter_Interface
{
    public function filter($value) 
    {
    	return Minify_HTML::minify($value, array(
    	    'cssMinifier' => array('Minify_CSS', 'minify'),
            'jsMinifier' => array('JSMin', 'minify')
    	));
    }
}

Next and final step is letting our project know we want to use this new filter globally, so add the following code in your bootstrap:

public function _initMinifyHTML()
{
    $this->bootstrap('view');
    $view = $this->getResource('view');
    $view->addFilterPath('My/View/Filter', 'My_View_Filter');
    $view->setFilter('Minify');		
}

Ecocheque : opencart payment module

I’ve created a small and humble module for the big and powerful Opencart shopping system. This module basicly allows people to checkout for free, so they can pay their order on delivery (like ‘Rembours’) with so called ‘Ecocheques’, only in Belgium!

You can download a copy from this module in the extension shop (download here) or pull it from github: https://github.com/kryap/opencart-ecocheque-payment-module


1. Just to be safe, make a backup of your OpenCart installation

2. Upload the contents of the 'upload' folder to your OpenCart installation. No files are overwritten.

3. Log in to the admin control panel and go to:
Extensions > Modules > Payments > Install

4. Done

PHPBenelux Conference 2012

So last weekend I went to my first #phpbnl12 conference in Edegem, Antwerp, and I must say. This was one of the best conferences I’ve attended so far! Great talks, great people, open bar every night, bbq, kinect, free bowling, belgian beer, am I missing something?

Anyway here’s a list of the talks: http://conference.phpbenelux.eu/2012/talks/ , and the by now famous after movie:

Hello World!

Welcome to my blog! I’ve been thinking of launching a blog for years now and never actually did it.. But now.. I feel inspired by all the new people I’ve recently met and I want to spread my knowledge. How many times was I looking for a solution and found it one some geek blog. Well I’d like to be that geek blog for once.

Don’t expect too many posts though.. I’m not that good of a writer and most posts will be about interesting things I found out about. But hey, stay tuned!