Pragmatism in the real world

Simple Zend_Form File Upload Example

UPDATE: This is out of date. Nowadays, you want to use Zend_Form_Element_File. Zend Framework 1.5's Zend_Form component is missing support for the file input element as it is waiting on a file upload component to build upon. We're busy people, so we'll fake it… This is a super simple example showing how to do file uploads with Zend_Form in Zend Framework 1.5. I'm building on the Simple Zend_Form Example, so make sure you have read… continue reading.

Updated Tutorial for Zend Framework 1.5

Zend Framework 1.5 has now been released to mark the occasion I have significantly updated my Zend Framework Tutorial! The tutorial was first released on 16th August 2006 and was written against version 0.1 of Zend Framework and had one major revision to bring in support for the ViewRenderer component. The new tutorial produces exactly the same application as before, but now uses the new 1.5 goodies of Zend_Form and Zend_Layout, so you can see… continue reading.

Simple Zend_Form Example

Following on from the Simple Zend_Layout Example, Zend_Form is now in the trunk, so here's a super simple, complete example that shows it in action: (clearly the form is unstyled :) You can construct a Zend_Form directly from a config file or can build it in code. This example builds it in code. Setting up This example uses the same basic skeleton as the Zend_Layout code with the addition of a forms directory: As you… continue reading.

A View Stream with Zend_View

One of my biggest issues with using PHP as the templating engine in View scripts is that the easiest way to echo a variable is the least secure. Consider: <?= $this->var ?> Perfectly legal, dead easy to understand, but doesn't escape $var which is what you want more often than not. To resolve this you need something like: <?= $this->escape($this->var) ?> But who remembers to do that?! I don't and I have short-open-tags turned off… continue reading.

Subversion Externals

Subversion's svn:externals property is the mechanism that is used to automatically check out data from other repositories into your working directory. This post is to remind me how to do it as each time I need the information, I end up Googling for it. To start, let's assume you have a lib/ directory and want to put ZF's library/ and incubator/library/ code within it so that the result looks like this: myApplication/ lib/ incubator/Zend/ Zend/… continue reading.

UK PHP Conference

I'm not sure how many people follow my the Zend Framework in Action website yet, so I thought I'd advertise here that I've just posted about my upcoming session at the UK PHP Conference. Go and read it and then subscribe to the RSS feed!

Simple Zend_Layout Example

Zend_Layout is in the trunk now, so here's a super simple MVC example that shows it in action: This example consists of three view files: the outer layout file, the index action view script and a right hand side bar. The remainder of this post describes the key files. If you just want to poke around with the code, then it's at the bottom, so page down now! Setting up This is the directory layout:… continue reading.

Where to set up your view?

With Zend_Layout on the horizon, I've been looking at how to use it and it will remove the need for my own front controller plugin which I call SiteTemplate. As a result, I need to find a new home for the view customisation stuff I do in SiteTemplate. My current plan is to create a new front controller plugin called ViewSetup (for want of a better name!) that contains just the view setup stuff from… continue reading.

Zend_View: Access the view from a view helper

It's in the manual, but I thought I'd blog about my simple View Helper setup that ensures that I can get at the view with minimal effort. Firstly we create a parent class: < ?php abstract class My_View_Helper_Abstract { protected $_view; public function setView($view) { $this->_view = $view; } } This class contains the code required by Zend_View to collect an instance of the view and assign it to a protected variable. All my view… continue reading.

Back to zero bugs

I've just finished going through the open Zend_Config issues and fixing them all. Nothing major, but a couple of nice fixes and one new function. The bugs recently fixed are: ZF-2209 Zend_Config* contructor should have the section defaults to null ZF-2162 Zend_Config_Xml usage without sections bug ZF-2021 Zend_Config::toArray() does not support generic object values Lastly, I've added a new function called setReadOnly() in response to issue ZF-2061. This allows you to lock down a Zend_Config… continue reading.