HomePHP Page 2 - The Zend Framework: an Introduction
Downloading and Installing the Zend Framework - PHP
In this second part of a four-part series on the MVC paradigm and the Zend framework, you'll learn what the framework can help you accomplish and how to install it. This article is excerpted from the chapter 25 of the book Beginning PHP and Oracle: From Novice to Professional, written by W. Jason Gilmore and Bob Bryla (Apress; ISBN: 1590597702).
Proceed to http://framework.zend.com/download to download the latest stable version of the Zend Framework. There are three available options for retrieving the source code, including downloading zip and tar packages, or checking out the code from Zend's Subversion repository. Choose whichever option is most convenient for you, uncompress the code if you choose one of the former options, and move the library directory to a convenient location, within the PHP installation directory's includes directory, for instance. Only this library directory is relevant, so you can disregard all other files in the uncompressed package. Also, consider changing the library directory name to something very easy to reference, such as zfw.
Caution The Zend Framework requires PHP 5.1.4 or newer.
Because the Zend Framework works by routing all requests through a single script, you'll also need to configure Apaches mod_rewrite module. Create an .htaccess file and place the following contents in it, saving the file to the document root:
RewriteEngine on RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php
Note Apache's mod_rewrite module is a powerful feature of Apache used to manipulate requested URLs. On Windows, mod_rewrite is disabled by default. To enable it, you'll need to open up httpd.conf and uncomment the line LoadModule rewrite_module modules/mod_rewrite.so, update the appropriate AllowOverride directive to allow .htaccess files to be used, and then restart the Apache server. See the Apache documentation for more information about this directive.
Finally, because you'll need to reference several Zend Framework components from within your application, and it's always wise to ensure maximum application portability, this directory should be directly accessible by appending it to the php.ini file's include_path directive. For example, on Linux this directive might look like this:
If you don't have control over the php.ini file, not to worry; you can place the following directive in the .htaccess file, which should reside in the server's document root:
The Zend Framework has been configured. If you added the include_path information to php.ini, you'll need to restart your Web server in order for the changes to take effect.
Please check back next week for the third part of this article.