Create RESTful Applications Using The Zend Framework - Tutorial Series
In the first two posts of this series, we discussed how to route REST requests to controllers and return HTTP response code. In this article I will talk about managing API keys.
Having the clients send API key within the HTTP header is convenient to handle. We can quickly check the HTTP request header and decide whether to allow or deny the request.
As a prerequisite you should be familiar writing front controller plugins. Let's write a front controller plugin that does the following:
In our last example, we used Zend_Rest_Route and Zend_Rest_Controller to demonstrate how to map requests to controller actions. We also used the response object to send text content in the HTTP response. In this article let us send appropriate HTTP response codes using the response object.
RFC 2616 describes HTTP response codes to use in various contexts.
In this example, we will use a few response codes
Title: Zend Framework 1.8 Web Application Development
Author: Keith Pope
Publisher: Packt Publishing Ltd
ISBN 1847194222
ISBN 13 978-1-847194-22-0

The Zend Framework community needed a book covering version 1.8+. Version 1.8 brought new notable features. Zend_Application is one among them. Zend_Application introduced object oriented bootstrapping in applications that otherwise used a procedural script. A bunch of users had difficulty understanding how to set up their applications to make use of the new bootstrapping component. All of them have seem to understand it well now, thanks to support in the official mailing lists and IRC channel. Zend_Navigation, Zend_Tool and enhancements to filter and validation components were other noteworthy additions to Zend Framework 1.8. For a full list of changes and additions to the 1.8 version see the release notes.
I contacted PackT Publishing Ltd and asked for the book to write this review. They were kind enough to quickly send me a copy of the ebook.
Let's begin exploring the book.
The Zend Framework 1.9 release added a new feature - Zend_Rest_Controller. Zend_Rest_Controller and Zend_Rest_Route classes go hand in hand. In the previous versions of the Zend Framework, we have had the Zend_Rest_Server component. We still have. Since Zend_Rest_Server provides an RPC like component violating the REST architectural constraint, it is likely to be deprecated in the future versions of the Zend Framework.
The scenario:
PHP language provides the mail() function. But it requires properly configured mail server on the local machine. Developers often don't have the necessary infrastructure at their disposal. Sometimes sending emails from a PHP script becomes a frustrating experience.
A lot of people have asked which is the best PHP framework out there. Which one suits a beginner? Which one best suits a company? How to convince a friend or boss to use Zend Framework?
In this article I present some information about Zend Framework. This is not a comparison of frameworks. When I started programming with PHP I used to roll out my own framework of sorts. As it happens to every other programmer I started exploring other's code. I started using few classes from PHPClasses.org and then from PEAR. I have been using components from Zend Framework since version 0.1. Today, at Binary Vibes we have built several applications using Zend Framework. It really has worked out well for us. We have also built a middle ware suite on top of Zend Framework which we tend to use for most of our projects. Therefore, my opinion about Zend Framework might be a bit biased. I try to be open to new ideas nevertheless.
Zend Technologies is the company that sponsors few developers to contribute to The Zend Engine, the core of PHP. The company together with the community develops the Zend Framework. Naturally, the quote, "from the makers of PHP" comes into being. One of the objectives of the Zend Framework is to promote best practices involved in application development.
A few months back, our friend Ben Scholzen wrote about setting up the environment variable in your Zend Framework powered application.
With the advent of Zend Framework 1.8 and the Zend_Application component the Zend Framework Quick Start guide recommends this setting.
<?php
Zend_Controller_Action_HelperBroker::getStaticHelper('helpername');
?>For example, you can access the redirector helper from within your front controller plugin:
<?php
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
?>
Recent comments
7 hours 31 min ago
9 hours 52 min ago
1 day 2 hours ago
2 days 3 hours ago
2 days 5 hours ago
3 days 8 hours ago
3 days 12 hours ago
3 days 13 hours ago
3 days 17 hours ago
4 days 5 hours ago