How should I run external function from routes?

I am new to Slim and I don’t understand how can I solve my problem.

I have separate file PHP called functions.php where I have function that saves information about requests in my DB.
This is on of my routes

$app->get('/api/something', function($request, $response) {
    require_once('dbconnect.php');
    include_once('functions.php');

    log_request($some_params);
});

And it is my functions.php file

require_once('dbconnect.php');
function log_request($params) {
    global $mysqli;
    $query = "INSERT INTO log_table (....) VALUES (...) ";
    $mysqli->query($query); 
}

For some reason this code is not working because $mysqli inside function is null. What is wrong?