Making a custom front controller in Zend Framework

Tags:

Firstly, apologies for the lack of posts lately. I’m pretty busy with various things right now, so I don’t have much time for blogging. Hopefully I’ll have some pretty interesting/cool stuff to show you later, though! Now, here’s something interesting I spotted recently: Creating a custom front controller for Zend Framework. Federico Cargnelutti is writing a series of posts on …

Integrating FCKeditor with Zend_Form

Tags:

How to use FCKeditor, or any other WYSIWYG editor, with Zend_Form? Another relatively common question. There are many ways you can do this, but let’s look at these two as they are the best in my opinion: Adding some JavaScript to your view script Creating a Zend_Form_Decorator We’ll be using FCKeditor, but you can apply the techniques shown to others, …

Using a builder to construct complex classes

Tags:

Sometimes if you have a complex class, which needs to be set up in a specific way: Perhaps it takes a lot of constructor arguments, or often requires calling some setters. Having something like that can make it more difficult to understand the code. In a case like this, you may want to consider using a builder class, which is …

Improved PDF generation with RE Framework RE_Pdf

Tags:

I’ve previously written a post on creating a PDF generator class using Zend_Pdf, which detailed some Zend_Pdf usage and introduced a class which could be used to create PDFs easily based on an XML configuration file or such. Zend_Pdf, while generally quite good, has one big issue: It does not support word wrapping text! There’s a new and still a …

Zend_Controller actions that accept parameters?

Tags:

In some MVC style frameworks the controller’s action methods take parameters in the method signature, ie. someMethod($userId) Zend Framework controllers do not – in ZF, you access parameters through the request object in the controller itself. I thought it would be nice to get the parameters you want in the method, so let’s check out how to do that and …

Database backed Zend_Form elements

Tags:

A relatively common task when working with forms is filling select boxes or checkbox and radiobutton lists from a database. It’s not very tricky to query a database, and fill a Zend_Form element’s possible values from the resultset, but it can be quite boring and extraneous code…
We could also create an element which we can give some SQL, and it’ll fill itself automatically! This way you can even define database-backed elements in XML or INI configuration files.

Sending files better: Apache mod_xsendfile and PHP

Tags:

I have previously written a quick post on making files downloadable through PHP scripts. The example in the post reads the file itself into a variable, and as pointed out in the comments, it’s not necessarily a very good idea especially if you deal with large files. Recently at work, we needed a reliable way to send files to users’ …

Handling errors in Zend Framework

Tags:

In Zend Framework based applications, error handling is typically done using the error controller, but there are different ways to send the execution to it – some better than others. Let’s look at some ways to trigger the error controller and how to have it handle different error conditions.

Creating a simple abstract model to reduce boilerplate code

Tags:

In a usual scenario involving models in PHP, you will have some repeating things: You will usually need getters and setters for the model’s properties, you will need to be able to construct the model from an SQL query or such, and you’ll also need to write SQL queries for the models. While none of this is very complex, it’s …