Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony generate full URL

Tags:

symfony

I need to generate full URL with symfony, for now I have :

$this->generateUrl('my_route', array('type' => 'param')

This function generate something like : /my_project/xxxxxxxxx

Is there a function like generateUrl for generate a fully URL ? I need the HTTP and the domain name.

I know I can add them manually but If there is a function for that it's better.

Thanks

like image 380
Clément Andraud Avatar asked Jan 15 '16 13:01

Clément Andraud


1 Answers

It is quite easy:

$this->generateUrl('my_route', array('type' => 'param'), UrlGeneratorInterface::ABSOLUTE_URL);

Don't forget to add:

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
like image 89
Michaël Perrin Avatar answered Oct 02 '22 17:10

Michaël Perrin