How do I call a controller method from a twig template and passing arguments to it?
Passing arguments in route parameters

I think the missing part is the route that you have defined for the controller. You have to use this to generate the url:

$url = Url::fromRoute('entity.node.canonical', ['node' =&gt; 1]);


This example is for the node controller and passes the argument nid=1. The parameter names are defined in the route definition.

Passing arguments in query parameters

I've seen in one of your other posts that you want to use query parameters. This is an example for the user login:

$url = Url::fromRoute('user.login', [], ['query' =&gt; ['destination' =&gt; 'http://example.com']]);


For this to work you don't need to define a query parameter in the route. Simply inject the request as function argument (the request is always available to a controller, it's not necessary to define it in the route) and get the query parameter:

use Symfony\Component\HttpFoundation\Request;

  public function myController(Request $request) {

    $destination = $request-&gt;query-&gt;get('destination');

  }