I try to make simple app with Twig/View template renderer and I get 500 error. I follow official documentations steps, but it does not work.
Structure

Index.php
Dependencies.php
Routes.php

Please, i you can, tell me, where is my mistake is? And why i have no error description, yet ‘displayErrorDetails’ => true.
             
            
              
              
              
            
            
           
          
            
            
              This is my container part:
// Register twig on container
$container['view'] = function ($container) {
    $settings = $container->get('settings');
    $view = new \Slim\Views\Twig(
        $settings['view']['template_path'],
        $settings['view']['twig']
    );
    // Instantiate and add Slim specific extension
    //$view->addExtension(new Slim\Views\TwigExtension($container['router'], ''));
    $view->addExtension(new SpecialExtension($container));
    // global twig values
    $view->offsetSet('common', 'src/Common/views/');
    return $view;
};
Somewhere in my frontendcontroller:
/**
 * Return the page: index
 *
 * @Method 'GET', 'POST'
 */
public function index()
{
    return $this->view->render($this->response, $this->templateDir . '/index.twig', []);
}
or if you want to see the twig (html) result before you sent it away:
/**
 * Return the page: index
 */
public function index()
{
    $result = $this->view->fetch($this->templateDir . '/index.twig',
        [
            'myvar' => 'a value for the twig template'
        ]
    );
    $this->response->getBody()->write($result);
    return $this->response;
}
I always end my twig templates with .twig, and phpstorm can recognize them (color syntaxing and so on)
             
            
              
              
              1 Like
            
            
           
          
            
            
              A 500 error will log to your server’s log file which will give you the best clue as to where things went wrong.
             
            
              
              
              2 Likes
            
            
           
          
            
            
              Thanks for your answers, guys,
I fogot about Apache logs. I looked them and found my problem - Php Version Miscompatability.