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) {


And it is my functions.php file

function log_request($params) {
    global $mysqli;
    $query = "INSERT INTO log_table (....) VALUES (...) ";

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