Improving Ajax performance in Zend Framework applications

Tags:

A common reason to use Ajax in a website is to make it feel faster, so you usually want Ajax requests be processed as quickly as possible.

While there are many ways to speed up Zend Framework based applications, there are still some things like routing and dispatching which still add up to the total.

There is, however, another way to make Ajax work even faster

A french translation of this post by Antoine Delaisse is available at “Le blog du Zend Framework”

Read More

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 bit obscure framework called RE Framework, which has an excellent PDF component – it includes support for word wrapping, better support for PDF templates, image loading etc.

Let’s check out how to use RE_Pdf to improve the earlier CU_PdfGenerator class!

Read More

Twitter thoughts

Tags:

I’ve been using Twitter for a while now. You can find me here.

But what about Twitter? What’s it useful for? How to cope with the constant stream of mostly unimportant updates from the ton of people you follow?

Read More

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 even add a little automatic validation along the way.

Read More

A more user-friendly date-based search

Tags:

Recently in one of my freelance projects, the client needed a feature that allows them to search the database for records with a date between two specific dates.

Rather than opting for the typical three text fields + a date selector, I added a little trick to make it better…

Read More

Object-Oriented JavaScript book review

Tags:

I was recently contacted by Packt Publishing, and asked if I wanted to review a book they published – Object-Oriented JavaScript, written by Stoyan Stefanov. I hadn’t reviewed books before, but I decided to give it a shot!

As stated on Packt’s website, by reading the book you will learn:

Create scalable, reusable high-quality JavaScript applications and libraries

  • Learn to think in JavaScript, the language of the web browser
  • Object-oriented programming made accessible and understandable to web developers
  • Do it yourself: experiment with examples that can be used in your own scripts
  • Write better, more maintainable JavaScript code

It also says:

After reading this book, you’ll be prepared to ace your JavaScript job interview and even impress with some bits that the interviewer maybe didn’t know. You should read this book if you want to be able to take your JavaScript skills to a new level of sophistication.

which would definitely be a benefit, don’t you think so?

Does the book deliver all this?

Read More

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.

Read More

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’ browser, and I decided to take a look at mod_xsendfile, as suggested by Tom Graham.

It’s also supported by other web servers such as Lighttpd and nginx.

Read More

Using Prototype Property in JavaScript

Tags:

I have been asked to review the book “Object-Oriented JavaScript” by Stoyan Stefanov, and published by Packt Publishing. The review is not quite ready yet, but in the meantime, here’s some exclusive content from the book for you to have a look at.

The following topics are discussed in this article:

  • Every function has a prototype property and it contains an object
  • Adding properties to the prototype object
  • Using the properties added to the prototype
  • The difference between own properties and properties of the prototype
  • __proto__, the secret link every object keeps to its prototype
  • Methods such as isPrototypeOf(), hasOwnProperty(), and
    propertyIsEnumerable()

Read More

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.

Read More