


Symfony2 implements the method of obtaining the url in the controller, symfony2controller_PHP tutorial
Symfony2 implements the method of obtaining the url in the controller, symfony2controller
This article describes the example of Symfony2 implementing the method of obtaining the url in the controller. Share it with everyone for your reference, the details are as follows:
// 假设当前URL地址是http://192.168.1.100/demo/web/app_dev.php/m/index $request = $this->getRequest(); // http or https 此处为http $request->getScheme(); // 192.168.1.100 $request->getHttpHost(); // http://192.168.1.100 $request->getSchemeAndHttpHost(); // /demo/web/ $request->getBasePath(); // /demo/index.php $request->getBaseUrl(); // eg: /demo/web/app_dev.php/user/login 不一定是/demo/web/app_dev.php/m/index 取决于routeName $this->generateUrl('routeName'); // routeName $routeName = $request->get('_route');
I hope this article will be helpful to everyone’s PHP program design based on the Symfony framework.
Articles you may be interested in:
- Detailed examples of creating projects and template settings with the Symfony2 framework
- How to create projects using the symfony command
- Symfony page Detailed explanation of basic creation examples
- Analysis of date usage in twig of symfony2.4
- Summary of session and cookie usage in Symfony2
- Summary of the method of obtaining data from the database in Symfony2
- Detailed explanation of form usage of Symfony2 framework study notes
- Detailed explanation of HTTP Cache usage of Symfony2 framework study notes
- Plug-in format analysis of Symfony2 study notes
- Symfony2 study notes system Detailed explanation of routing
- Detailed explanation of controller usage in Symfony2 study notes
- Detailed explanation of template usage in Symfony2 study notes
- Detailed explanation of Symfony2 creation page instance

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 reason for the error is NameResolutionError(self.host,self,e)frome, which is an exception type in the urllib3 library. The reason for this error is that DNS resolution failed, that is, the host name or IP address attempted to be resolved cannot be found. This may be caused by the entered URL address being incorrect or the DNS server being temporarily unavailable. How to solve this error There may be several ways to solve this error: Check whether the entered URL address is correct and make sure it is accessible Make sure the DNS server is available, you can try using the "ping" command on the command line to test whether the DNS server is available Try accessing the website using the IP address instead of the hostname if behind a proxy

1. The professions that can be changed to "Male Ghost Sword" are: Red Eye, Devil May Cry (Shura and Sword Soul have been launched in the Korean server, and are expected to be launched in the second batch) 2. The professions that can be changed to "Female Fighting" are: Sanda, Qigong 3. The professions that can be changed by "Male Gunner" are: Roaming, Gunslinger 4, and the professions that can be changed by "Female Magic" are: Elemental, Magic Scholar 5, and the professions that can be changed by "Female Priest" are: Paladin

PHP function introduction—get_headers(): Overview of obtaining the response header information of the URL: In PHP development, we often need to obtain the response header information of the web page or remote resource. The PHP function get_headers() can easily obtain the response header information of the target URL and return it in the form of an array. This article will introduce the usage of get_headers() function and provide some related code examples. Usage of get_headers() function: get_header

Since the release of the domestic game version in February, NetEase's mysterious shooting game "Operation Apocalypse" has attracted the curiosity of many players. As we all know, although NetEase also had some shooting games in the early years, it seems that except for "The Day After Tomorrow" and "Knives Out", there are not many playable games. In recent years, the works launched by NetEase have gained momentum and have achieved considerable results in many niche tracks. The fact that "Operation Apocalypse", which has never been exposed before, is placed as the first shot of NetEase in the new year is enough to raise eyebrows. Is this a signal that NetEase is going to launch an attack on the shooting track? Players are eagerly looking forward to new mobile shooting games. , on March 13, this 5V5 multi-hero skills shooting mobile game "Operation Apocalypse" developed by NetEase finally unveiled its mystery and officially released its first live demonstration

On March 25, the "Eternal Tribulation" mobile game conducted a preview live broadcast one month after receiving the version number. Producer Guan Lei personally demonstrated the actual game screen and core gameplay during the live broadcast. This is also the first time the real-life footage of the mobile game "Eternal Tribulation" has been released publicly. Judging from the live footage released, the mobile game "Eternal Tribulation" continues the core gameplay of the PC martial arts chicken game, and all mechanisms and techniques such as flying ropes, vibrating knives, and combos are also restored. In order to adapt to the operation of the mobile terminal, the mobile game has made drastic changes to the operation buttons. It retains the core gameplay of the terminal game while simplifying the operation of the mobile terminal. It innovatively uses the UI form of "roulette" operation: click to attack, Press and hold to charge, slide left to vibrate the sword, and slide up to raise the dragon. Various attack modes can be easily completed through different operations of one button, but still maintain

Differences: 1. Different definitions, url is a uniform resource locator, and html is a hypertext markup language; 2. There can be many urls in an html, but only one html page can exist in a url; 3. html refers to is a web page, and url refers to the website address.

When a SpringBoot novice creates a project, the Controller cannot be scanned for a series of problems 1.2.3.4.5.6. Another way is to add @ComponentScan(basePackages={"xxx.xxx.xx","xxx.xxx" when starting the service class) .xx”}) is the fully qualified name of the package, which can be used for multiple SpringBoot custom controllers. The SpringBoot custom controller route cannot be scanned and cannot be found because the startup class and the custom Controller package are not in the same directory. Officially recommended placement of application.java

Journey through the vastness and set foot on the journey to the west! Today, Zhengtu IP officially announced that it will launch a cross-border cooperation with CCTV animation "Journey to the West" to jointly create a cultural feast that combines tradition and innovation! This cooperation not only marks the in-depth cooperation between the two major domestic classic brands, but also demonstrates the unremitting efforts and persistence of the Zhengtu series on the road of promoting Chinese traditional culture. Since its birth, the Zhengtu series has been loved by players for its profound cultural heritage and diversified gameplay. In terms of cultural inheritance, the Zhengtu series has always maintained respect and love for traditional Chinese culture, and skillfully integrated traditional cultural elements into the game, bringing more fun and inspiration to players. The CCTV animation "Journey to the West" is a classic that has accompanied the growth of generations.
