Symfony生成完整的URL

Clé*_*aud 3 symfony

我需要用symfony生成完整的URL,现在我有:

$this->generateUrl('my_route', array('type' => 'param')
Run Code Online (Sandbox Code Playgroud)

此函数生成类似于: /my_project/xxxxxxxxx

是否有generateUrl生成完整URL的功能?我需要HTTP和域名.

我知道我可以手动添加它们但是如果有功能那就更好了.

谢谢

Mic*_*rin 12

这很容易:

$this->generateUrl('my_route', array('type' => 'param'), UrlGeneratorInterface::ABSOLUTE_URL);
Run Code Online (Sandbox Code Playgroud)

别忘了添加:

use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
Run Code Online (Sandbox Code Playgroud)