Environment configuration for getting started with Zend Framework and a Hello World example (with demo source code download), zenddemo
This article describes the environment configuration of Zend Framework and the first Hello World Program. We will share this with you for your reference. The details are as follows:
Step 1: Confirm your PHP environment:
1. Ask PHPer to check whether your PHP version is above 5.2.0. If not, update it to 5.2.0. Otherwise, the Zend Framework may not work. I have tried it myself.
Have encountered such a problem... so please test your own .. PHP source code Latest Version: http://www.php.net/downloads.php.
2. After your PHP environment is configured, open the php. ini file and check whether the PDO extension is enabled. If not, remove the number before extension = php_pdo.dll.
3. Open the httpd. conf file in the APACHE folder. Find the mod_rewrite module of apache and check whether LoadModule rewrite_module modules/mod_rewrite.so is enabled. If not, remove the # sign before it.
4. Find the httpd. conf file. If AllowOverride is set to None, change None to all. In this way, you can write files such as. htaccess ..
5. Restart your APACHE server so that Zend Framewrok can be used in our PHP environment.
Step 2: Obtain the Zend Framework source code:
1. download the latest version of Zend Framework source code. The latest version seems to be 1.7.0, but it may be unstable. Therefore, ask PHPer to decide the version to use.
You can download the latest source code from http://www.zendframework.com/download/latest.
Step 3: Create a project directory:
I don't want to talk about anything .. I will show the image .. is the project directory of my tutorial... I have explained above .. you can create a directory as follows .. of course, I will provide the source code for download below.
However, it is recommended that you do it yourself to learn more. I also provide the source code for your reference.
Step 4: program description:
I will not talk about anything here. because each file contains annotations. I don't think it's too difficult. if some friends do not understand, please leave a message on the blog. I will follow this blog .. try to answer your questions .. thank you ..
Index. php (website portal) file and description:
<? Phperror_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 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 basic path-> setParam ('noviewrenderer', true)-> setControllerDirectory ('. /application/controllers ')-> throwExceptions (true)-> dispatch ();
IndexController. php file and description:
<? Phpclass 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 () {// assign a value to the variable in index. the phtml template shows $ this-> view-> bodyTitle = '
Description of index. phtml template file:
<? = $ This-> bodyTitle;?> <! -- Output the value passed by Action in the Controller: hello world -->
Click here to download the complete instance code.
However, Zend is not added to my library. Please add it to your PHPer. If you have any questions, please leave a message for me.