How to get current route in Symfony 2

0 votes

How do I get the current route in Symfony 2?

For example, routing.yml:

somePage:
   pattern: /page/
   defaults: { _controller: "AcmeBundle:Test:index" }

How can I get this somePage value?

Apr 15, 2020 in PHP by kartik
• 37,490 points
402 views

1 answer to this question.

0 votes

Hii,

 The easiest way to do this:

class MyController extends Controller
{
    public function myAction($_route)
    {
        var_dump($_route);
    }

    .....

Hope this works!!

Thank You!!

answered Apr 15, 2020 by Niroj
• 82,560 points

Related Questions In PHP

0 votes
1 answer

How to route GET and POST for same pattern in Laravel?

Hello @kartik, You could try the following: Route::controller('login','AuthController'); Then in ...READ MORE

answered Nov 22, 2020 in PHP by Niroj
• 82,560 points
60 views
0 votes
1 answer

How to get the http headers from current request in PHP?

Hello, Try this code: if (!function_exists('getallheaders')) { ...READ MORE

answered Nov 23, 2020 in PHP by Niroj
• 82,560 points
71 views
0 votes
1 answer

How to get the client IP address in PHP ?

Hello, Here is a code sample of a good ...READ MORE

answered Apr 8, 2020 in PHP by Niroj
• 82,560 points
2,876 views
0 votes
1 answer

How to get Redux Form data in another Component?

Hello @kartik, What you need to do is ...READ MORE

answered Jun 1, 2020 in PHP by Niroj
• 82,560 points
1,034 views
0 votes
1 answer

Why it is necessary to refresh CSRF token per form request?

Hello, Generating a new CSRF token for each ...READ MORE

answered Mar 19, 2020 in Laravel by Niroj
• 82,560 points
1,541 views
0 votes
1 answer

What is meant by passing the variable by value and reference in PHP?

Hello, When the variable is passed as value ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,560 points
286 views
0 votes
1 answer

Connection with MySQL server using PHP. How can we do that?

Hey @kartik, You have to provide MySQL hostname, ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,560 points
149 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,560 points
274 views
0 votes
1 answer

How to get the current plugin directory in WordPress?

Hello @kartik, This will actually get the result ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,560 points
479 views
0 votes
1 answer

How to get current URL path in PHP?

Hello @kartik, Use $_SERVER['REQUEST_URI'].  The URI which was given in ...READ MORE

answered Aug 31, 2020 in PHP by Niroj
• 82,560 points
827 views