intro
Let’s try to install Zend Framework 1.5 and do first few steps of Official ZF QuickStart. You can download the source code of this article from here.
1. Download
Let’s download the latest version of Zend Framework 1.5 from Zend Framework download site.
2.Structure of the Directories
Structure of the directories is same as QuickStart
1:Copy library directory of Zend Framework.
2:This directory is the document root. It changes by your environment, it might be www, public_html and so on. The application and library directories must be inaccessible via your web server.
1 2 3 4 5 6 7 8 |
~/ +application/ | +controllers/ | +views/ | +scripts/ | +index/ +library/ <---- 1 +public/ <---- 2 |
1:Copy library directory of Zend Framework.
2:This directory is the document root. It changes by your environment, it might be www, public_html and so on. The application and library directories must be inaccessible via your web server.
3.Create a Rewrite rule
Create the file
public/.htaccess
with the following content.
1 2 3 |
RewriteEngine on #RewriteBase /yourBaseURL RewriteRule !\.(js|ico|gif|jpg|png|css)$ index.php |
4.Create Index File
Create the file
public/index.php
with the following content.
1 2 3 4 |
<?php require '../application/bootstrap.php'; //If you use absolute path, uncomment the following lines. //require '/path/to/application/bootstrap.php'; |
5.Create Bootstrap File
Create the file
application/bootstrap.php
with the following content.
1 2 3 4 5 6 7 8 9 10 11 |
<?php set_include_path('../library' . PATH_SEPARATOR . get_include_path()); /** @see Zend_Controller_Front */ require_once 'Zend/Controller/Front.php'; Zend_Controller_Front::run('../application/controllers'); //If you use absolute path, uncomment the following lines. //set_include_path('/path/to/library' . PATH_SEPARATOR . get_include_path()); //require_once 'Zend/Controller/Front.php'; //Zend_Controller_Front::run('/path/to/application/controllers'); |
6.Create Index Controller
Create the file
application/constorllers/IndexController.php
with the following content.
1 2 3 4 5 6 7 8 9 10 |
<?php /** @see Zend_Controller_Action */ require_once 'Zend/Controller/Action.php'; class IndexController extends Zend_Controller_Action { public function indexAction() { } } |
7.Create View
Create the file
application/views/scripts/index/index.phtml
as following content.
1 2 3 4 5 6 7 8 9 10 11 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Zend Framework Quick Start</title> </head> <body> <h1 id="4_zend-framework-mvc-a_1" >Zend Framework MVC at your service!</h1> </body> </html> |
8.Check
Let’s access your web server(ex.http://localhost/). If it goes well, you can see ‘Zend Framework MVC at your service!’.
If you got some errors like 404 Not Found, Please try to use the RewriteBase rule of .htaccess file and absolute path of index.php and bootstrap.php.
If you got some errors like 404 Not Found, Please try to use the RewriteBase rule of .htaccess file and absolute path of index.php and bootstrap.php.
Next
I will try next few steps of the QuickStart.