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