Saturday, November 24, 2007 8:37:21 PM
PHP, Zend Framework
Lately, the Zend_Layout component has been a very popular topic on
#zftalk. It is indeed a very useful component, but a lot of people are having trouble understanding how it works.
Adding to the confusion is the outdated documentation regarding the component proposal and the equally outdated articles about Zend/Xend_Layout.
Let’s demonstrate the usage of the current Zend_Layout implementation, which can be found from the Zend Framework SVN or Snapshots in the Incubator directory.
Read the rest of the post at codeutopia.net
Thursday, November 22, 2007 9:08:11 AM
PHP, Zend Framework, web
Internationalization and localization means making your site usable in more than one languages. Well, to be honest, you could call a site that's only in english localized to english visitors too, but in any case...
These two are also known as I18N and L10N. Can you guess where these acronyms come from? The first and last letter from each word and then the number of letters between... Someone's been feeling really creative

While PHP has an extension for GNU Gettext, which can be used for localization, it isn't the easiest thing to use. Additionally, PHP can also do number and money formatting based on the locale, but this depends on the server: You must have the locale installed on it. On Shared Hosting accounts, some locales may be unavailable and you may not be able to install them. Not to mention that gettext can be a bit of a hassle to get working.
So, rather than using PHP's native support, why not use Zend Framework's Zend_Locale and Zend_Translate?
Read the rest of the post at codeutopia.net
Friday, November 16, 2007 2:43:25 PM
PHP, Zend Framework
We were talking about routing on the
#zftalk IRC channel. One of the users mentioned that rather than using routes, he was using the __call method in the IndexController.
I then asked him why is he doing that, as I knew routes would be more than a good choice for most kinds of URLs.
I found out that he was working with
SEO and he was using a very interesting URL scheme: domain.com/productname-numbers-categoryname.html
This is actually quite interesting thing to think about. Not the SEO part, but how to make ZF understand these kind of URLs. The default routing in Zend Framework works very well for typical Zend'ish URLs like domain.com/hello/world/stuff/goes/here, but if you want to do some more specialized URLs, like the example here, you may need to do some thinking.
Because ZF is so flexible, I can think of
four different ways to route complex URLs:
- Using __call
- Using a controller plugin
- Using Zend_Controller_Router_Route_Regex
- Customizing the Route class
These methods can be used for other things as SEO URLs as well, so let's check out how to utilize these four and their pros and cons.
Read the rest of the post at codeutopia.net
Wednesday, November 14, 2007 10:49:48 AM
Zend Framework
I've had a couple of cases where I've wanted to quickly test some stuff with the Zend Framework. Now, to get the framework up and running, you'll need a couple of things:
-
Directory structure - controller dirs, view dirs, public_html, etc. etc.
-
.htaccess files - To enable routing
- Bootstrap
- Controllers
I can never remember what to put in the .htaccess files and I often forget the parameters for the front controller in the bootstrap. But what if you could do all these steps with a single command?
I want to be able to run a single command and get the framework up and running without doing anything else.
So, I decided to whip up my trusty
Vim and write a couple of shell scripts to do it!
Read the rest of the post at codeutopia.net
Saturday, November 10, 2007 8:21:44 AM
PHP, Zend Framework
Escaping any data which comes from the server is important to escape, as it prevents XSS amongst other things.
The Zend Framework view component Zend_View let’s you escape template variables with $this->escape($this->variableName), but it doesn’t escape them by default. Wouldn’t it be much nicer if it did that by default, or at least provided you with a variable to turn it on/off?
Let’s find out how to do that!
Read the rest of the post at codeutopia.net
Thursday, November 8, 2007 11:36:06 AM
PHP, Zend Framework
I've posted a couple of posts related to integrating Smarty with the Zend Framework:
- Making a Smarty view class based on Zend_View
- Integrating Zend View Helpers into Smarty
I've also posted some Zend_View related posts:
- Using layouts with the Zend ViewRenderer helper
- Creating a factory-object for building views
Let's wrap up these in a summary of using them and what else could be done regarding these and the view solution in general.
Read the rest of the post at codeutopia.net
Saturday, November 3, 2007 7:58:11 PM
source code, Zend Framework, PHP
Coming on again with the Smarty and Zend View related articles, let's this time take a look at how to get Zend's View Helpers running with Smarty.
Other examples for this that I have seen use a syntax like this: {helper helper=Url p='array(something)' p2=stuff}, which is kind of ugly and the array parsing is done with eval, and we know that
Eval is Evil.
Wouldn't a more elegant solution let you use helpers just like you use Smarty plugins? In the style of just typing the name of the helper and simple parameters? Let's see how to make that happen!
Read more...
Friday, October 26, 2007 4:57:17 PM
Ajax, Zend Framework
Doing Ajax is quite simple these days with the various JavaScript libraries offering easy ways to do it. But how do you do it on the server side, without complicating things too much?
Typically, in addition to the Ajax response, you need a traditional page response to a request as well - for example, for browsers which don't support Ajax.
Let's look at some methods how one can detect if a request is an Ajax request and how to respond to them in the Zend Framework.
Read more...
Monday, October 15, 2007 9:01:23 AM
PHP, Zend Framework, web applications
Let's take a look at one of my biggest PHP projects so far:
Reservinator 1.0, or in other words, a very advanced place reservation system for LAN parties. The page is in finnish, but the post is not, so read on!
If you've even been to a LAN party, you might've used something similar to this system. Amongst other features, Reservinator let's you view an overview map of the event location, choose your place by clicking the place you wish to reserve, and sign up for competitions.
It also has various admin tools, such as sending email to users, marking their reservations as paid based on the bill reference number, and biggest of all, building the overview map with a very easy to use drag and drop interface for placing rooms, tables and other things.
Read more...
Wednesday, September 19, 2007 1:25:59 PM
Zend Framework, PHP
Continuing on posts related to
making a CMS with the Zend Framework, todays topic is Zend_Controller_Router_Route, Zend_Controller_Router and customizing the routing in Zend Framework.
The default routing scheme is like this: site.com/module/controller/action. While this works just fine for "normal" sites, it doesn't work very well for a CMS. This is because you would need to create copies of controllers if you wanted to have many similar pages or having longer URLs with the page name as a parameter in the end.
I wanted a better URL scheme for my CMS: site.com/module/page/action where module and action are optional. As you can see, there is no variable for the controller, so how do we tell the framework which controller the request needs to be routed to?
Read more...