Automatic route matching and manual allocation-php Tutorial

Source: Internet
Author: User
Is the route automatically matched or manually allocated? For example, the routing of the tp framework can automatically match the module method, and the routing of the laravel framework needs to be manually allocated. What are their respective advantages and disadvantages? Is the route automatically matched or manually allocated? For example, the routing of the tp framework can automatically match the module method, and the routing of the laravel framework needs to be manually allocated. What are their respective advantages and disadvantages?

Reply content:

Is the route automatically matched or manually allocated? For example, the routing of the tp framework can automatically match the module method, and the routing of the laravel framework needs to be manually allocated. What are their respective advantages and disadvantages?

Reply from Station v

In Rails, I have seen wildcard routing Matching. after tens of thousands of lines are written in the result program, I don't know how many interfaces my program has exposed. Looking back at the sorting and restructuring, it was really a vomiting blood. The methods in the Controller do not dare to be deleted randomly. Otherwise, it would be nice to break the AK when an external call of automatic routing is triggered.

I can only say that the automatic allocation framework is extremely rare. most of them are manually allocated. The difference is whether to create a route table or directly annotate the function.

Each has its own advantages,

  1. Let's talk about automatic allocation. in some enterprise management software, there is a problem on which page there are no good-looking URLs or good routing functions, after reading the url, the maintenance personnel will probably know which controller has a problem and which method has a problem. it is also very easy to assign permissions to rbac, for exampleorder/createThe system administrator has a little understanding of the rule and knows that this is the order controller create method. to create an order permission, just add the order module create action to the background permission list.
    If it is manually assigned, it is allocated according to the programmer.order/createIt may be the add method of the order controller, which is used for permission detection.order_store

  2. Compared with automatic allocation, I prefer manual allocation, with a high degree of freedom. the advantages of the above automatic allocation can also be obtained through forced management, that is, the learning cost is higher and the efficiency is not discussed.

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.