Symfony2 Implementing a method for obtaining URLs in a controller, symfony2controller_php tutorial

Source: Internet
Author: User

Symfony2 implements the method of obtaining the URL in the controller, Symfony2controller


The example in this article describes the method by which Symfony2 implements obtaining URLs in a controller. Share to everyone for your reference, as follows:

Assume that the current URL address is http://192.168.1.100/demo/web/app_dev.php/m/index$request = $this->getrequest ();//HTTP or HTTPS Here is 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 is not necessarily/demo/web/app_dev.php/m/index depending on routename$this->generateurl (' RouteName ' );//Routename$routename = $request->get (' _route ');

It is hoped that this article is helpful to the PHP program design based on Symfony framework.

Articles you may be interested in:

    • Symfony2 framework Create project and template Setup examples
    • Ways to create a project using the Symfony command
    • Symfony A basic example of creating a page
    • Analysis of date usage in twig of symfony2.4
    • Summary of Symfony2 's session and cookie usage
    • Symfony2 a summary of how to achieve data acquisition from a database
    • Symfony2 Framework Learning Notes Form usage
    • Symfony2 Framework Learning Notes HTTP cache usage
    • Analysis of plugin format of Symfony2 learning notes
    • Symfony2 Study Notes System routing
    • Symfony2 study notes of the controller usage detailed
    • Symfony2 Study Notes Template usage detailed
    • Symfony2 Creating a Page instance

http://www.bkjia.com/PHPjc/1111907.html www.bkjia.com true http://www.bkjia.com/PHPjc/1111907.html techarticle Symfony2 implements the method of obtaining the URL in the controller, Symfony2controller This article describes the Symfony2 implementation method to obtain the URL in the controller. Share to everyone for your reference, specific as ...

  • 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.