简体   繁体   中英

Getting 500 internal server error while using twig in slim framework

I am trying to use twig in slim but it is showing internal server error 500 in console.just don't know why it is showing it

Here is my code

require 'vendor/autoload.php'; 
date_default_timezone_set('America/New_York');

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

$app = new \Slim\Slim(array(
    'view' => new \Slim\Views\Twig()
));

$view = $app->view();
$view->parserOptions = array(
    'debug' => true,
);
$view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),
);

$app->get('/', function () use($app) {
    $app->render('index.twig');
});
$app->get('/contact', function () use($app) {
    $app->render('contact.html');
});
$app->run();

Change

$app = new \Slim\Slim(array(
    'view' => new \Slim\Views\Twig()
));

to

$app = new \Slim\Slim(array(
    'view' => new \Slim\Views\Twig(),
    'debug' => true,
));

You should now see a better error message.

The error's probably something to do with not being able to find the template files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM