Simple configuration of ZendFramework-PHP Tutorial

Source: Internet
Author: User
Tags autoloader
Simple configuration of the ZendFramework framework. Because the project needs to use the ZendFramework framework, we are now going to learn more about this framework. The first lesson always outputs HelloWorld. Configure the PHP environment for ZendFramework to run. First, check that the Zend Framework is used for the project, so now you can learn more about this Framework. The first lesson always outputs Hello World.

Configure the PHP environment for Zend Framework running

First, check your PHP environment. Zend Framework requires that the PHP version be no lower than 5.1.4. However, we strongly recommend that you use version 5.2.3 or later, because there are many major security and performance improvements between the two versions.

After the 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.

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.

Find the httpd. conf file. if AllowOverride is set to None, change None to all, so that you can write files such as. htaccess.

Restart your APACHE server so that Zend Framewrok can be used in our PHP environment.

Configure Zend Framework project

The project folder is as follows:

The following describes the file name and code to be modified.

Index. php (website portal) file and description:

 SetFallbackAutoloader (true); $ registry = Zend_Registry: getInstance (); $ view = new Zend_View (); $ view-> setScriptPath ('. /application/views/scripts/'); // sets the template display path $ registry ['View'] = $ view; // registers view // sets the controller $ frontController = Zend_Controller_Front:: getInstance (); $ frontController-> setBaseUrl ('/zendframework') // set the basic path-> setParam ('noviewrenderer', true)-> setControllerDirectory ('. /application/controllers ')-> throw Exceptions (true)-> dispatch ();?>

IndexController. php file and description:

 Registry = Zend_Registry: getInstance (); $ this-> view = $ this-> registry ['View']; $ this-> view-> baseUrl = $ this-> _ request-> getBaseUrl ();}/** outputs the Hello World Action )! */Function indexAction () {// assign a value to the variable. in the index. phtml template, $ this-> view-> bodyTitle = 'Hello World! is displayed! '; Echo $ this-> view-> render ('index. phpml'); // Display template}?>

Description of index. phtml template file:

 BodyTitle;?>
 

Enter http: // localhost/zendframework/in the browser to output Hello World.

PS: Error message: Zend_Loader: registerAutoload is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead

Zend_Loader: autoload and Zend_Loader: autoload are not recommended from version 1.8.0 and will be removed from version 2.0.0. Zend_Loader_Autoloader is recommended to replace Zend_Loader: autoload.

If

require_once('Zend/Loader.php'); Zend_Loader::registerAutoload();

Change

require_once 'Zend/Loader/Autoloader.php';Zend_Loader_Autoloader::getInstance();

The system prompts Fatal error: Class 'templater' not found in/var/www/phpweb20/htdocs/index. php on line 35.

I think it should be a failure to load the class, because the path clearly contains the 'templater' class, and the problem should still occur in Zend_Loader_Autoloader.

Change

require_once "Zend/Loader/Autoloader.php";Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);

OK!

Framework. The first lesson always outputs Hello World. To configure the PHP environment for Zend Framework running, first confirm...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.