This time I will bring you the aliasing and binding of thinkphp. What are the precautions for aliasing and binding of thinkphp? The following is a practical case, let’s take a look.
1. Routing alias
17:02:53
Use alias: math represents the following path. To access, you need to add methods and parameters after math
Whitelist and blacklist: ext means the suffix needs to be added
Static array:
Another example:
You need to add the root directory, otherwise access will start from public , access needs to add the method name
2. Route binding
a, Entry binding: divided into two levels
Directly enter the method name when accessing
b. Automatic binding of entrance:
New entry file:
File in the controller under the admin module
c, Dynamic binding:
Bind to index module:
d. Bind to namespace or class: directly locate the specified module or specified controller
If the namespace is bound to app\index\controller, always use this name All controllers under the space can directly use the
route file under thecustom folder:
app\index\ There are two classes under the controller. Dome and Class can be accessed without writing the module name
Bind to current url class:
(Access, direct access method)
The above is the detailed content of thinkphp road by aliases and bindings. For more information, please follow other related articles on the PHP Chinese website!