Yaf learn to start from the beginning

Source: Internet
Author: User

One. The portal file is the entry for all requests, usually with the aid of the rewrite (regular) rule, which redirects all requests (

Redirection (Redirect) is the way in which various network requests are redirected to another location through various methods to the portal file.

Example 3.2. A classic entry filepublic/index.php

<?phpdefine ("App_path",  Realpath (dirname (__file__). ‘/.. /‘)); /* The upper-level *   ////definition constant pointing to public app_path $app  = new Yaf_application (App_path. "/conf/application.ini"); $app->run ();

$app  = new Yaf_application (App_path. "/conf/application.ini");//Initialize a Yaf_application object based on the path's file

An understanding of the *.ini document There is an example on the Internet
http://clisvoi.blog.163.com/blog/static/20149805020151710726737/
public void yaf_application::run ( void)

Runs a yaf_application, starts accepting and processing requests, distributes routes, and responds accordingly. The response is eventually returned to the client

Two. Rewrite rules

Unless we use the routing protocol based on query string (yaf_route_simple, Yaf_route_supervar), we will need to use the rewrite rules provided by webserver to put all requests for this application, are directed to the entry file mentioned above.

Example 3.4. Nginx's rewrite (nginx.conf)

server {  Listen * * *;  server_name  domain.com;  Root   document_root;  Index  index.php index.html index.htm;  if (!-e $request _filename) {    rewrite ^/(. *)  /index.php/$1 last;  }}

Yaf learn to start from the beginning

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.