How to work with Symfony Routing a separate component?

Good afternoon. Wanted for my project to stick a routing from Symfony.
The documentation I read, I began to do it (without annotation, as they obviously need to put the Symphony itself), and something I tuplyu on
The same algorithm right?
1) register of ranting and cable controllers
$routes = new routecollection an();
$routes->add('home', new Route('/', ['_controller' => [HomeController::class, 'index']]));
$routes->add('article', new Route('/article', [ '_controller' => [ArticleController::class, 'index']]));

2) Next make
$context = new RequestContext();
$request = Request::createFromGlobals();
$matcher = new UrlMatcher($routes, $context);
$parameters = $matcher->match($request->getPathInfo());
 // print_r($parameters);

Everything is OK If in the main, the print_r gives
Array ( [_controller] => Array ( [0] => App\controllers\HomeController [1] => index ) [_route] => home )

on the site/article
Array ( [_controller] => Array ( [0] => App\lib\ArticleController [1] => index ) [_route] => article )

For those that are not, gives
ResourceNotFoundException: No routes found for ... that too ,in General, correct.
And that should translate directly to the controller? What am I missing?
class HomeController {

 public function __construct() {

 public function index() {
 print_r('Home Controller'); 


Does not display the "Home Controller".
What am I missing?
April 3rd 20 at 17:27
1 answer
April 3rd 20 at 17:29
It depends on your application.
You can, for example, use, would be something like

$parameters = $matcher->match($request->getPathInfo());
$invoker = new Invoker\Invoker(null, $container);
$invoker->call($parameters['_controller'], $parameters);

If no container, something like
$parameters = $matcher->match($request->getPathInfo());
list($class, $action) = $parameters['_controller'];
$controller = new $class;

But passing arguments via an array - not very convenient.
Yes, of course, better with the container. He, in General, is still needed for the application. Thank you very much - Genesis.OKon commented on April 3rd 20 at 17:32
And, in fact, all I could think about call_user_func() ( - Genesis.OKon commented on April 3rd 20 at 17:35
It is strange that there is no example with the native symfony HttpKernel: - Lupe_Murp commented on April 3rd 20 at 17:38

Find more questions by tags Symfony