symfony routing component (The Routing Component)
The Routing component converts the HTTP request into a series of configuration parameters.
Installation
You have two ways to install this component:
<code>通过 Composer (symfony/routing on Packagist); 使用官方的 Git repository (https://github.com/symfony/Routing)。 </code>
Then, Composer is required to provide the vendor/autoload.php file to the autoloading mechanism . Otherwise, your application will not find this component.
Usage
You need the following three parts to set up the basic routing system:
- RouteCollection, which contains the definition of the route (instances of the class Route)
- RequestContext, information about the request;
- UrlMatcher, which matches the request into A single route (that is, determine which route needs to be used)
Here is a simple example. Here you need to make sure your autoloader has loaded this component:
<code><span>use</span><span>Symfony</span>\<span>Component</span>\<span>Routing</span>\<span>Matcher</span>\<span>UrlMatcher</span>; <span>use</span><span>Symfony</span>\<span>Component</span>\<span>Routing</span>\<span>RequestContext</span>; <span>use</span><span>Symfony</span>\<span>Component</span>\<span>Routing</span>\<span>RouteCollection</span>; <span>use</span><span>Symfony</span>\<span>Component</span>\<span>Routing</span>\<span>Route</span>; <span>$route</span> = <span>new</span> Route(<span>'/foo'</span>, <span>array</span>(<span>'controller'</span> => <span>'MyController'</span>)); <span>$routes</span> = <span>new</span> RouteCollection(); <span>$routes</span>->add(<span>'route_name'</span>, <span>$route</span>); <span>$context</span> = <span>new</span> RequestContext(<span>$_SERVER</span>[<span>'REQUEST_URI'</span>]); <span>$matcher</span> = <span>new</span> UrlMatcher(<span>$routes</span>, <span>$context</span>); <span>$parameters</span> = <span>$matcher</span>->match(<span>'/foo'</span>); <span>// array('controller' => 'MyController', '_route' => 'route_name')</span></code>
It should be noted that when using $_SERVER[‘REQUEST_URI’], any parameters can be included in the URL. A simple solution is to use the HttpFoundation component, which is explained below.
To be continued
Original link:
http://symfony.com/doc/current/components/routing/introduction.html
The above has introduced the symfony routing component (The Routing Component), including aspects of it. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The Chinese meaning of request is "request". It is a global variable in PHP and is an array containing "$_POST", "$_GET" and "$_COOKIE". The "$_REQUEST" variable can obtain data and COOKIE information submitted by POST or GET.

Calling the @Bean annotated method in the @Configuration class returns the same example; calling the @Bean annotated method in the @Component class returns a new instance.

How to use the urllib.request.urlopen() function in Python3.x to send a GET request. In network programming, we often need to obtain data from a remote server by sending an HTTP request. In Python, we can use the urllib.request.urlopen() function in the urllib module to send an HTTP request and get the response returned by the server. This article will introduce how to use

1. Basic dynamic introduction of components: Simple dynamic introduction means that the front end knows which components to introduce, and introduces multiple components into the parent component, but does not render it. After certain conditions are met, it will be rendered at a certain location. specified component. import{reactive,ref,shallowReactive,onActivated,defineAsyncComponent,}from'vue';constcustomModal=defineAsyncComponent(()=>import('./modal/CustomM

Vue.js is a popular front-end framework that provides many APIs for component customization. This article will introduce the mixin, extend, component and other APIs in Vue to help you master the skills of component customization. Mixin Mixin is a way to reuse component code in Vue. It allows us to reuse already written code into different components, thereby reducing the need to write duplicate code. For example, we can use mixins to help us combine multiple groups

1. Create a new file called request.js and import Axios: importaxiosfrom'axios'; 2. Create a function called request and export it: This will create a function called request and export it Set up a new Axios instance with a base URL. To add timeout settings in a wrapped Axios instance, you can pass the timeout option when creating the Axios instance. exportconstrequest=axios.create({baseURL:'https://example.

Request in PHP refers to request. It is a super global variable in PHP. It is used to collect data submitted by HTML forms and parameters in URLs. It can obtain data from GET and POST requests at the same time. Note that $_request is an associative array. , where the keys are the names of the form fields and the values are the values of the form fields. When using the $_request variable, user-entered data should always be validated and filtered to avoid security issues.

The Request object in PHP is an object used to handle HTTP requests sent by the client to the server. Through the Request object, we can obtain the client's request information, such as request method, request header information, request parameters, etc., so as to process and respond to the request. In PHP, you can use global variables such as $_REQUEST, $_GET, $_POST, etc. to obtain requested information, but these variables are not objects, but arrays. In order to process request information more flexibly and conveniently, you can
