1. Installation
Download the latest version from the Zend Framework website. After unzipping, copy the entire directory to an ideal location, such as: /php/library/Zend.
Open the php.ini file and confirm that the path containing the Zend directory is defined in include_path. Taking the above configuration as an example, there should be entries similar to the following in php.ini:
include_path = ".:/php/library"
Note: The writing method under Windows is slightly different and should be similar to include_path = ".; C:phplibrary"
The initial installation is that simple. Some components of Zend Framework use some additional modules of PHP. Please refer here for specific requirements.
2. Project directory structure
If your project does not contain multiple modules, you can use the following directory structure:
application/controllers/IndexController.phpmodels/views/scripts/index/index.phtmlhelpers/filters/html /.htaccessindex.php If your project will contain multiple modules (for example: blog, community, etc.), then it is recommended to use a modular directory structure.
3. The root directory of the web page
The root directory of the web page should point to the html folder in the above directory structure.
4. Rewrite rules
Edit the html/.htaccess file and add the following two lines:
RewriteEngine onRewriteRule !.(js|ico|gif|jpg|png|CSS)$ index.php Note: The above is for apache Configuration. If it is another server, please refer to here.
5. Bootloader
Edit the html/index.php file and enter the following code:
Zend Framework’s default routing rule is http://domain name/controller name/action (method) name. For example:
http://example.com/user/show will be parsed to the controller named User and the show method defined in the controller. If this method is not defined, it defaults to the index method.
Note: In the code, Controller should be added after the controller name, and Action should be added after the action name.
Edit the application/controllers/IndexController.php file and enter:
/**Zend_Controller_Action*/
require_once'Zend/Controller/Action.php';
classIndexControllerextendsZend_Controller_Action
{
public functionindexAction()
{
}
}
7. View (page) script
Edit application/views/scripts/index/index.phtml, enter:
-//W3C//DTD XHTML 1.0 Strict //EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Hello, World!
8. Error ControllerBy default, the Zend Framework error handling plug-in is registered. It requires an error controller to handle errors. The default error control handling is assumed to be the ErrorController and the errorAction defined in it.
Edit application/controllers/ErrorController.php, enter:
/**Zend_Controller_Action*/
require_once'Zend/Controller/Action.php';
classErrorControllerextendsZend_Controller_Action
{
public functionerrorAction()
{
}
}
The following is the corresponding view script. Edit application/views/scripts/error/error.phtml and enter:
-//W3C//DTD XHTML 1.0 Strict//EN""http://www.w3.org/TR/ xhtml1/DTD/xhtml1-strict.dtd">
ErrorAn error occurred
An error occurred; please try again later.
9. RunOkay, now run the website. Type the following three addresses into the browser, and the result should be the same - the most common "Hello, World!".
http://domain name
http://domain name/index
http://domain name/index/index
If this is the case, then congratulations!
The above is the introduction to Zend Framework (1)-quick start. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.