Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Zend Framework

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use Zend Framework, the introduction in the article is very detailed, has a certain reference value, interested friends must read!

The details are as follows:

.htaccess file

The. Htaccess file is used to implement a URL reset, that is, when a user accesses a resource, it is relocated under the specified file.

Code example:

RewriteEngine onRewriteRule!\. (js | ico | gif | jpg | png | css) $index.php

Where line 1 indicates that the reset engine is on, and line 2 indicates that when accessing files other than js, ico, gif, jpg, png, css

Will be reset to the index.php file.

Note:

This rewrite rule can only be used for Apache servers and requires the redirection module of Apache. If you want to be effective, turn on the function. Confirm that under the httpd.conf configuration file of Apache

# LoadModule rewrite_module modules/mod_rewrite.so

Open, that is, remove #.

Automatically generate catalogs

After the downloaded zend is unzipped, there will be two core directories, one is library and the other is bin. There is a zf.bat file under bin that can be used to intelligently generate the Zend Framework directory structure.

But it must be configured before use, that is, the configuration of environment variables. Only in this way can its command be invoked directly. Otherwise, the build command cannot be invoked.

I. configure environment variables

The configuration process is shown in the figure:

After adding the path, you can call the instruction directly in the "small black box", that is, CMD. Two are configured here, one is the bin directory under zend, and the other is the php directory under xampp. Because the instruction needs to use some files in these two directories.

Whether the test is successful or not

The information in the figure above indicates that the environment variable has been configured successfully.

Third, execute the generation instruction

Zf create project zfdemo

At this point, a project directory is generated, as shown in the above prompt. There will be a directory zfdemo under disk C.

Copy the information in the directory to the project folder and test

The entry file here is under public

So enter the address "http://localhost/zendDemo/public/"" in the browser

Note: the project name is zendDemo.

If nothing goes wrong, you will see the result of successful implementation. As shown in the following figure:

Note: because I rewrote the default view file, all I saw was the word "Hello in the world".

Reform

First, create your own controller

Create a controller named SelfController.php in the application/controllers/ directory and enter the following code.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report