1. สร้าง Bootstrap File หรือ /srv/www/htdocs/index.php มีข้อมูลดังนี้
โค้ด: เลือกทั้งหมด
<?php
define('ROOT_DIR', dirname(dirname(__FILE__)));
//Error Reporting
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'on');
//Declare PATH Type1
//Modify include PATH
ini_set('include_path', ini_get('include_path')
. PATH_SEPARATOR . '../application/models'
. PATH_SEPARATOR . '../library');
// Zend Framework Include for ZF 1.7.3 or below
//require_once "Zend/Loader.php";
//Zend_Loader::registerAutoload();
//Zend_Loader::loadClass('Zend_Controller_Front');
// Zend Framework Include for ZF 1.8.0 or above
//see more info : http://framework.zend.com/manual/en/zend.loader.autoloader.html
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);
Zend_Loader::loadClass('Zend_Controller_Front');
//get the front contorller instance
$front = Zend_Controller_front::getInstance();
$front->throwExceptions(true);
$front->setControllerDirectory('../application/controllers');
//Go Go Go
$front->dispatch();
?>
โค้ด: เลือกทั้งหมด
<?php
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
echo "<h1>Hello World</h1></center>";
}
}
?>
4.เปิด browser ชี้ URL ไปที่ http://127.0.0.1 ถ้าถูกต้องจะได้ข้อความ "Hello World" อยู่ตรงกลางหน้า หรือ เรียก เป็น http://localhost ก็ได้
สำรับใครสร้างงานไว้ที่ www/test ก็เรียก
http://localhost/test
นะครับ
ที่มาบทความนี้และต่อๆ ไปจะเน้นมาจาก : phayoune.org
ขอบคุณ อ. ไว้ ณ. ที่นี้ด้วย