Home Backend Development PHP Tutorial yaf routing configuration rules_PHP tutorial

yaf routing configuration rules_PHP tutorial

Jul 20, 2016 am 11:14 AM
yaf use Check frame source code of rule access routing meet Configuration default

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to evaluate the cost-effectiveness of commercial support for Java frameworks How to evaluate the cost-effectiveness of commercial support for Java frameworks Jun 05, 2024 pm 05:25 PM

Evaluating the cost/performance of commercial support for a Java framework involves the following steps: Determine the required level of assurance and service level agreement (SLA) guarantees. The experience and expertise of the research support team. Consider additional services such as upgrades, troubleshooting, and performance optimization. Weigh business support costs against risk mitigation and increased efficiency.

Rules and exceptions for pointer comparisons? Rules and exceptions for pointer comparisons? Jun 04, 2024 pm 06:01 PM

In C/C++, the pointer comparison rules are as follows: pointers pointing to the same object are equal. Pointers to different objects are not equal. Exception: Pointers to null addresses are equal.

What is Bitget Launchpool? How to use Bitget Launchpool? What is Bitget Launchpool? How to use Bitget Launchpool? Jun 07, 2024 pm 12:06 PM

BitgetLaunchpool is a dynamic platform designed for all cryptocurrency enthusiasts. BitgetLaunchpool stands out with its unique offering. Here, you can stake your tokens to unlock more rewards, including airdrops, high returns, and a generous prize pool exclusive to early participants. What is BitgetLaunchpool? BitgetLaunchpool is a cryptocurrency platform where tokens can be staked and earned with user-friendly terms and conditions. By investing BGB or other tokens in Launchpool, users have the opportunity to receive free airdrops, earnings and participate in generous bonus pools. The income from pledged assets is calculated within T+1 hours, and the rewards are based on

How does the learning curve of PHP frameworks compare to other language frameworks? How does the learning curve of PHP frameworks compare to other language frameworks? Jun 06, 2024 pm 12:41 PM

The learning curve of a PHP framework depends on language proficiency, framework complexity, documentation quality, and community support. The learning curve of PHP frameworks is higher when compared to Python frameworks and lower when compared to Ruby frameworks. Compared to Java frameworks, PHP frameworks have a moderate learning curve but a shorter time to get started.

How do the lightweight options of PHP frameworks affect application performance? How do the lightweight options of PHP frameworks affect application performance? Jun 06, 2024 am 10:53 AM

The lightweight PHP framework improves application performance through small size and low resource consumption. Its features include: small size, fast startup, low memory usage, improved response speed and throughput, and reduced resource consumption. Practical case: SlimFramework creates REST API, only 500KB, high responsiveness and high throughput

How to choose the best golang framework for different application scenarios How to choose the best golang framework for different application scenarios Jun 05, 2024 pm 04:05 PM

Choose the best Go framework based on application scenarios: consider application type, language features, performance requirements, and ecosystem. Common Go frameworks: Gin (Web application), Echo (Web service), Fiber (high throughput), gorm (ORM), fasthttp (speed). Practical case: building REST API (Fiber) and interacting with the database (gorm). Choose a framework: choose fasthttp for key performance, Gin/Echo for flexible web applications, and gorm for database interaction.

Detailed practical explanation of golang framework development: Questions and Answers Detailed practical explanation of golang framework development: Questions and Answers Jun 06, 2024 am 10:57 AM

In Go framework development, common challenges and their solutions are: Error handling: Use the errors package for management, and use middleware to centrally handle errors. Authentication and authorization: Integrate third-party libraries and create custom middleware to check credentials. Concurrency processing: Use goroutines, mutexes, and channels to control resource access. Unit testing: Use gotest packages, mocks, and stubs for isolation, and code coverage tools to ensure sufficiency. Deployment and monitoring: Use Docker containers to package deployments, set up data backups, and track performance and errors with logging and monitoring tools.

What are the common misunderstandings in the learning process of Golang framework? What are the common misunderstandings in the learning process of Golang framework? Jun 05, 2024 pm 09:59 PM

There are five misunderstandings in Go framework learning: over-reliance on the framework and limited flexibility. If you don’t follow the framework conventions, the code will be difficult to maintain. Using outdated libraries can cause security and compatibility issues. Excessive use of packages obfuscates code structure. Ignoring error handling leads to unexpected behavior and crashes.

See all articles