This example describes the environment configuration for the Zend Framework entry and the first Hello World program. Share to everyone for your reference, specific as follows:
The first step: Verify your PHP Environment:
1. Please phper confirm that your PHP version is above 5.2.0. If not, then. Please update to 5.2.0 otherwise. The Zend Framework doesn't seem to work. I've tried it myself.
Have encountered such a problem. So please test yourself. PHP source of the latest version of the download address: http://www.php.net/downloads.php.
2. After you have configured your PHP environment, open the php.ini file to confirm that the PDO extension is open. If not, please remove the extension=php_pdo.dll before the number.
3. Open the httpd.conf file inside the Apache folder. Find the Apache mod_rewrite module to confirm LoadModule Rewrite_module Modules/mod_ Whether the rewrite.so is open. If not, please remove the # number in front of it.
4. Find the httpd.conf file, if allowoverride is none. Please make sure that none is changed to all. So you write. htaccess Such documents will play a role.
5. Restart your Apache server. In this way our PHP environment can be used Zend Framewrok.
Step two: Get the Zend Framework source code:
1. Download the latest version of the Zend Framework source code. Now the latest edition seems to be 1.7.0. But fear of instability. So ask the phper to decide what version they are using.
You can download http://www.zendframework.com/download/latest the latest version of the source code here.
Step three: Create the project directory:
I don't want to say anything more. I'll show you the pictures. Is my project directory for this tutorial ... I have a description on it. You can set up the catalogue in the following way. Of course below I will provide the source download.
But it is recommended that friends must do their own hands. To learn more. I give also the source code is just for everyone as a reference.
Fourth Step: Procedure Description:
I don't have much to say here. Because there are annotations in every file. I don't think it's too hard. If some friends do not understand, please leave a message on the blog. I will pay attention to this blog. Try to answer your questions. Thank you..
index.php (site Entry) documents and instructions:
<?php
error_reporting (e_all| E_STRICT);
Date_default_timezone_set (' Asia/shanghai ');
Set_include_path ('. ') Path_separator. '. /library '. Path_separator. '. /application/models/'. Path_separator. Get_include_path ());
Require_once ' zend/loader.php '; Zend_loader::registerautoload ();
Set the Zend Framework to automatically load class files
$registry = Zend_registry::getinstance ();
Set the template display path $view = new Zend_view ();
$view->setscriptpath ('./application/views/scripts/');
$registry [' view '] = $view;//Register view
//Set controller
$frontController =zend_controller_front::getinstance ();
$frontController->setbaseurl ('/zendframework ')/Set the base path->setparam (' Noviewrenderer ', true)-> Setcontrollerdirectory ('./application/controllers ')->throwexceptions (True)->dispatch ();
indexcontroller.php Documents and Instructions:
<?php
class Indexcontroller extends Zend_controller_action {
function init () {
$this->registry = Zend_registry::getinstance ();
$this->view = $this->registry[' view ';
$this->view->baseurl = $this->_request->getbaseurl ();
}
function Indexaction () {
//here gives the variable a value, which is displayed in the index.phtml template
$this->view->bodytitle = '
index.phtml Template File Description:
<?= $this->bodytitle;?>
<!--Here the value of the action passed in the output controller: Hello World-->
Full instance code click here to download the site.
But I didn't add zend to my library. Please phper yourself. If you have any questions. Ask a friend to leave a message for me.
More interested in Zend related content readers can view the site topics: "The introduction of the Zend Framework frame", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Course", "PHP object-oriented Programming Program , "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on the Zend Framework.