Home > Backend Development > PHP Tutorial > yaf routing configuration rules_PHP tutorial

yaf routing configuration rules_PHP tutorial

WBOY
Release: 2016-07-20 11:14:52
Original
1308 people have browsed it

When accessing using the framework's default route , you will encounter some troubles. The source code cannot be viewed in this part and can only be analyzed through guesswork.

If the project has multiple modules, obviously using yaf's default static routing cannot meet the needs.

yafThe default configuration is as follows:

application.baseUri=&rdquo;/<span &rdquo;
;默认的脚本后缀名,一般可以不写
application.ext</span>=<span php

;视图的后缀名,可以为html,随意。
application.view.ext</span>=<span phtml
application.dispatcher.defaultModule</span>=<span Index
application.dispatcher.defaultController</span>=<span Index
application.dispatcher.defaultAction</span>=<span index
application.modules</span>=Index
Copy after login

Explain the functions in turn

application.baseUri=”/” This shows that the content to be parsed is after our domain. If our application is accessed through folder a, baseUri is /a. So the purpose of this baseuri is to indicate which parts are It needs routing to process which are the real paths.

The default module is Index,

application.dispatcher.defaultModule=Index

After testing this sentence, it was found that the modification is invalid, which means that the default module cannot be modified through configuration,

and

application.dispatcher.defaultController=Index

application.dispatcher.defaultAction=index

That is, the default controller and the default action can be assigned accordingly.

The next step is to add a module to the route. When creating a new module, the added module must be notified to the route, so that the route can respond to requests for new modules.

application.modules=Index uses this sentence. If you want to add a new module Myoo, you must write after Index, Myoo().

becomes application.modules=Index,Myoo

<span ├── modules
│   │   └── Myoo
│   │   │ ├── controllers
│   │   │ └── views
│   │   │  │ ├── ctrl
│   │   │  │ └── index</span>
Copy after login

<strong><span 注意:模块名字一定要和配置文件里面添加的模块名字一样,包括大小写!!</span></strong>
Copy after login

The routing of the original framework is basically the default module that can be changed, but the default controller and action cannot be changed, they are hard-coded index

The advantage of this situation is that each module has a designated controller and action. If you want to access the index controller indexaction of the myoo module, you only need to write a module name myoo.

Yaf is not available now. The default module is hard-coded, and the default controller and action are for the default module. Now if you want to access myoo/index/index/, you can only write all of them, not just myoo. Just write myoo without controller and Action and routing still don’t know where the final destination is, so they won’t look for it in the module anymore. Myoo is parsed into a controller of the default module, and then a 404 error is thrown,

There is no problem with this, it is enough.

But I think it is a bug that the default module cannot be changed, because if it cannot be changed, why should this configuration item be added?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/440251.htmlTechArticleWhen using the default route of the framework to access, you will encounter some problems. The source code cannot be viewed in this part. Can be analyzed through guesswork. If the project has multiple modules, obviously use...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template