phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Zend Framework Intro: Creating Index.php as Single Access File

Tag: framework, zend, zend framework, access file, controller, MVC   Category: PHP Framework
post: 08 Apr 2008 read: 2,133


Zend Framework Step By Step Tutorial - Part 3: As we know, at Zend Framework, index.php is a file that needed in the web root directory. This file is used for all page request. It is used for setting up the application's environtment, Zend framework's controller system, then running the application itself. This is Front Controller pattern.

Create a file named "index.php" within helloworld/web_root. Enter following code:


<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
date_default_timezone_set('Europe/London');

$rootDir = dirname(dirname(__FILE__));
set_include_path($rootDir . '/library' . PATH_SEPARATOR . get_include_path());

require_once 'Zend/Controller/Front.php';
Zend_Controller_Front::run('../application/controllers');

?>

Ok, let's look at this file in more detail. Line 2-4 is used for setup environtment. Line 3 to ensure that all errors or notices are displayed. Line 4 for setup default time zone.

include_path() specifies a list of directories where the require(), include() and fopen_with_path() functions look for files. You can set at php.ini. But, we don't have to do it. We can use set_include_path(). You can see at line 7.

This is the bootstrap file. Bootstrapping is the term used to describe starting the application up. The core of this code at line 9-10. This will instantiate and dispatch the front controller. It will route request to action controllers.



Series this article:
Zend Framework Intro: Folder Structure
Zend Framework Intro: Explaining Anatomy of Zend Framework Application
Zend Framework Intro: Creating Index.php as Single Access File
Zend Framework Intro: Creating Apache .htaccess
Zend Framework Intro: Creating Controller
Zend Framework Intro: Creating View

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting