Skip to content

Instantly share code, notes, and snippets.

@reficedev
Created November 20, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reficedev/f50f0ddd481a11ed98b1 to your computer and use it in GitHub Desktop.
Save reficedev/f50f0ddd481a11ed98b1 to your computer and use it in GitHub Desktop.
A way to get the current url in a symfony2 controller
<?php
public function newsDetailAction($slug)
{
$request = $this->getRequest();
$currentRoute = $request->attributes->get('_route');
$currentUrl = $this->get('router')->generate($currentRoute, array('slug' => $slug), true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment