This course contains the basics of Zend

Course introduction
Test Your Caliber
Interview Questions
Pragnya Meter Exam


Getting Started with Zend Framework

Regardless of your programming skills, you have decided to make your way into the Zend Framework world. Some of you might be new to programming; others might be seasoned developers heading a large team. Regardless of your status or reasons why you want to enter the Zend Framework world, everyone starts on the same page.Yes,stop your groaning; that means setting up the environment and dealing with the technology that will get you up and running toward building your application powered by Zend Framework.

You might be wondering why you need to go through this process. That’s fair; when I started developing PHP applications, I asked the same question—but I continued to follow the steps to set up the environment. Looking back to my experience, I can say that setting up the environment will give you a few things right away. For new developers, it will introduce the technology Zend Framework needs to successfully start developing applications. Think about it like this: if I gave you a box of tools and asked you to build a house, how on earth would you go about accomplishing that task if you didn’t know how to use each of the tools in the box? So you also need to learn which tools you need to build your figurative house: a Zend Framework application.

If you know which tools are needed to run applications, you will understand the limitations of those applications. If your boss came up to you, stared into your eyes, and (besides telling you that you rock) said, “I need a Zend Framework application that will handle ten million users per month, a few hundred thousand hits per minute and have a response time of less than a second. Can you do it?” You should be able to tell him, “Yeah, I rock. What’s new?” You can also say, “Yes! You’ll have it in a month, with all the bells and whistles you asked for.” I can’t promise that Zend Framework will handle 1,000 hits per second because that’s for your load balancer to handle, but I do promise that Zend Framework will make it fun for you to deliver the product on time.

The goal of this chapter is to set up a development environment with all the free tools available:

  • Apache 2.2
  • MySQL 5.1 or later
  • PHP 5.2.4 or later.
  • Zend Framework 1.8

You will also create your first Hello World application powered by Zend Framework and review the basic components required to power all Zend Framework applications efficiently.

Introducing Caching

To get a better understanding of what caching is, let’s use a quick example of a user arriving at the home page of a web site. The page contains many images and uses dynamic content derived from a database to populate it. When a user arrives at the page, the server must do a number of things. At a high level, the server must call each of the images from the directory to display, connect to the database, retrieve the data from the database tables, and present the data to the user.

Using the same flow, let’s view the process at a granular level: the CPU and memory level. At each of the steps, the data must be converted into bits: ones and zeros. With the bits converted, you present the data to the browser, which then formats the data into a nice web page for the user. The process described is costly compared with reading only from memory. Reading from memory is what caching is.

Taking the example currently in use to the next level, you’ll update the code behind the home page to use caching. When a user arrives at the home page, the data must be initially read from disk before it’s stored into memory. Requesting this in-memory data during subsequent requests then involves the process of loading the data using an identifier and determining whether there was a hit or a miss.

In cache lingo, a hit happens any time the request for the specific piece of cached data marked with the specified ID has been located. When a hit is made, the data is retrieved from the cache and used for processing. If the request does not locate the identified cached data, it is a miss. When you encounter a miss, you load the content from disk and place it into the cache for subsequent calls. Zend Framework has a similar approach.