Using global $app or $container in helper function

Shoude be good or bad when using global $app or $container in helper function?

Ex:

function view($name, $args = [], $status = 200) {
    global $container;
    $view = str_replace(".", "/", $name);
    return $container->view->render($container->response->withStatus($status), $view . '.php',$args);
}

No sure what the question is, but using global is always a bad idea

So, how can I create helper function like Laravel? Because, they needs to access $container?

I’m load helpers.php with modify composer.json:

"autoload": {
        "classmap": [
           //
        ],
        "psr-4": {
            "App\\": "app"
        },
        "files": [
            "helpers.php"
        ]
}