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,
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/create
The 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/create
It may be the add method of the order controller, which is used for permission detection.order_store
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.