The use of the undefined variable $router is confusing if you jump straight to http://symfony.com/doc/current/book/routing.html#generating-absolute-urls in the docs (as I did.)
[#2854] Fixing small bug thanks to @xabbuh