Create helpers for redirect of URL in views(MVC)

For a long time I’ve been looking for a solution to redirect or create links to my views (MVC) and I’ve created the following functions:

/*
* Declared globals on index.php
*/
$app->add(function (ServerRequestInterface $request, ResponseInterface $response, callable $next) {
  $route = $request->getAttribute('route');
  
  if (!empty($route)) {
  
  $GLOBALS['route'] = $route;
  $GLOBALS['router'] = $this->router;
  $GLOBALS['request'] = $request;
  $GLOBALS['response'] = $response;
  
  return $next($request, $response);

  }else{
     throw new NotFoundException($request, $response);
  }
});

/*
* Helpers declareds on helpers.php, initialized from composer;
*/
function createLinkFor($routerName, $argumento = false){
  if($argumento){
    return url($GLOBALS['router']->pathFor($routerName, $argumento));
  }else{
    return url($GLOBALS['router']->pathFor($routerName));
  }
}

function redirectTo($routerName){
  return $GLOBALS['response']->withRedirect($GLOBALS['router']->pathFor($routerName), 303);
}

function currentRoute($mostrarNome = false){
  if($mostrarNome ==  false){
    return  url($GLOBALS['route']->getPattern());
  }else{
    return  $GLOBALS['route']->getName();
  }
}

But these functions use $GLOBALS which in my opinion is a great gambiara and I realize that using them my application has an increase in RTTF and other slowdowns, using the SLIM3 or SLIM4 standards which would be the best solution?