Return multiple php files on 404 error

Hey there, I’m using Slim as the URL controller for my webpage, then I use simple PHP+HTML files to build my webpage GUI, this is giving me no problem and it’s been working perfectly, but I want to use a custom 404 php file as the Slim 404 default page, the only way I found on how to do that is the following:

// Create container
$container = new \Slim\Container;

// Register component on container
$container[‘view’] = function ($c) {
$view = new \Slim\Views\Twig(‘view/pages/’);
$view->addExtension(new \Slim\Views\TwigExtension(
$c[‘router’],
$c[‘request’]->getUri()
));
return $view;
};

//Override the default Not Found Handler
$container[‘notFoundHandler’] = function ($c) {
return function ($request, $response) use ($c) {
$c[‘view’]->render($response, ‘header.php’);
$c[‘view’]->render($response, ‘404.php’);
$c[‘view’]->render($response, ‘footer.php’);
return $response->withStatus(404);
};
};

$app = new \Slim\App($container);

The obvious problem here is that it expects a Twig file to build the interface, so it won’t parse the php code on my files, how can I return my php files normally on 404 so this page is rendered as the rest of the webpage?