Simple generation of route paths with Symfony Routing component

Code
<?php

use Symfony\Component\Routing\Router;
use 
Symfony\Component\Routing\Route;
use 
Symfony\Component\Routing\RouteCollection;
use 
Symfony\Component\Routing\Loader\ClosureLoader;
use 
Symfony\Component\Routing\Generator\UrlGeneratorInterface;

// a collection of routes
$collection = new RouteCollection();
$collection->add('foo', new Route('/foo'));
$collection->add('bar', new Route('/bar/{baz}'));
$collection->add('qux', new Route('/qux', [], [], [], 'example.com'));

// create Router
$closure = function () use ($collection) {
    return 
$collection;
};
$loader = new ClosureLoader();
$router = new Router($loader$closure);

// generate url by route name
dump(
    
$router->generate('foo'),
    
$router->generate('bar', ['baz' => 'param1']),
    
$router->generate('qux', [], UrlGeneratorInterface::ABSOLUTE_URL)
);
Result
"/foo"

"/bar/param1"

"http://example.com/qux"
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6