Feb 08

Been offline for two weeks…

…and I didn’t even notice it. That shows that I’m too busy with other things like finishing my book and finishing a project at work. Both will be done somewhere in march, so you can expect a new post around that time.

Apart from a new post, I will be paying attention to an older article on this blog about module configuration in Zend Framework. It is still a hot subject, and I have gotten some good questions and remarks from many commenters. I will answer all these questions, show more source code as requested and maybe I’ll even listen to some suggestions. ;-)

Oct 20

ZF: assigning objects to partials the easy way

Recently, I have been using view script partials (Zend_View_Helper_Partial) and wanted to assign an object as an object to a partial and have full use of it in the partial. I found the solution in the ZF manual very impractical and thought of another way to solve this. In this post I describe the ‘ZF manual’ way to do it, and my easier way.

Continue reading

Sep 03

Zend Framework: module specific frontcontroller plugins

Here is another situation I have run into while trying to build a modular application: sometimes you need to run a frontcontroller plugin ONLY when a specific module is requested. An example could be authentication. Say I have a public site and an admin section. The most obvious solution is to enable the authentication plugin only when the admin section is requested. This is something that is not possible with Zend_Application and the frontcontroller resource. So, as I did for loading module specific layouts, I wrote a frontcontroller plugin for registering module specific frontcontroller plugins: the Rexus_Controller_Plugin_RequestedModulePluginLoader. It works together with a Zend_Application resource called Rexus_Application_Resource_Moduleplugins. Let’s get started.

Continue reading

Sep 03

Writing a book about Zend Framework

I have been busy with this project for some time, but now I feel that I really have something to say: I have started writing a book about Zend Framework. Yay! Sadly, for all you non Dutch-speaking readers, the book is aimed at the Dutch market and will be written in Dutch. I am writing the book together with a co-writer, named Wouter Tengeler. He has written two (Dutch) PHP books before. The book will be published by Van Duuren Media, a small publisher specialized in technical and management books. It will be part of the series ‘Leer jezelf PROFESSIONEEL…’. The expected publish date will be in the first half of next year.

Sep 03

Some personal news: new job @ Ibuildings

Well, I’m back. I’ve been away on holiday and I have been busy talking to some possible new employers. But then I found out that Ibuildings was looking for a senior software engineer. Ibuildings is the leading PHP authority in the UK and The Netherlands, and is the representative of Zend Technologies in these countries. I’ve had my eye on them for a few years now, because their philosophy about the role of PHP directly mirrors my own. Also, they play an active role in the PHP-community and have a couple of very talented people working for them. I find that an inspiring environment, so I jumped on the opportunity and sent them an e-mail. Well, to make a long story short, I got the job and I am very happy to start at the Utrecht location in the Netherlands on October 2nd!

Jul 22

Zend Framework: htaccess url rewrite infinite loop

Just a short one this time. This is something I encountered at work today.
I started a new ZF project in our development environment, which makes use of dynamic virtualhosts.
When I started the application for the first time in the browser, I got an internal server error.

Of course I didn’t expect this. So I had a look at the apache logs and found entries like this:

[Wed Jul 22 16:00:26 2009] [debug] core.c(3052): [client] redirected from r->uri = /data/virtualhosts/dev/...

After some googling, I found out this has something to do with having apache rewrite rules in combination with dynamic virtualhosts. Then I had a look at an older ZF project on the same server and found a small but significant difference:

Standard .htaccess created by Zend_Tool:

SetEnv APPLICATION_ENV development
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

And here is the last line of the older .htaccess, the rest is identical:

RewriteRule ^.*$ /index.php [NC,L]

Notice the difference? There is a forward slash before index.php in the working .htaccess.
I simply added the forward slash in the non-working htaccess, and everything worked fine!

Note: this may not work for you, as I have seen articles where REMOVING the forward slash was the solution. It is entirely dependent on your specific apache config and more importantly, your apache version. This is because there have been changes in how apache matches redirects in recent releases.

Jul 19

Zend Framework: module specific layout

In this article I will show you how set up module specific layouts. Many people find it confusing that module resources like layouts are always loaded, regardless of the module requested. The reason for this is that at the time of bootstrap, the request is not yet determined and the application does not know what module was requested. To set up resources like layouts, databases, translations etc. for specific modules ONLY when that module is requested, your best bet is a front controller plugin or action helper.

Continue reading

Jul 09

Zend Framework: per module translation sources

Separate modules should be able to have separate Zend_Translate sources. As can be read in my earlier post about module configuration, I am making my modules completely autonomous in their config. That also means they should have their own translation sources that are automatically added to the main Zend_Translate instance for easy reference. In this article I will show you how to set this up.

Continue reading

Jul 07

Zend Framework: module config

Zend Framework supports modules, but in my opinion, not in a modular way. I have been trying to set up self-containing modules with their own configuration. The objective is to have an architecture where I can just drop a module in the modules directory, and it will work immediately without further configuration.

Now that there is Zend Application with the Modules Resource, that is almost possible. There is one problem. The module specific config still has to be put in application.ini. On the Zend Framework mailinglists, many people are clamoring for module specific configuration files. In this article I will explain how to set up modules with their own config files.

Continue reading

Apr 06

First Post

Welcome to my website. On this site I will be posting about all things that have to do with web development with some emphasis on Zend Framework. My aim is to provide a place where developers will find many useful tips and snippets to use in their own projects. To do that, I will not only publish about my own insights and code, but also about great pieces of code by other developers.

Let’s get started right away: I have started finetuning a generic grid component for Zend Framework that I have been using for my own projects for a while now. In my experience it severely cuts development time of web applications; because as we all know, web applications are at their core nothing more than lists and CRUD. There is a limitation that many people will regret: it can’t do everything. I will post the first draft with documentation soon.