I'm building a simple website in PHP with Slim Framework and Twig template engine.
I've installed Slim and Twig with Composer in the Command Line.
This is my index.php
<?php
require __DIR__ . '/vendor/autoload.php';
date_default_timezone_set('Europe/Copenhagen');
$app = new Slim\App( array (
'view' => new Slim\Views\Twig()
));
$view = $app->view();
$view->parserOptions = array(
'debug' => true
);
$view->parserExtensions = array(
new \Slim\Views\Twig(),
);
$app->get('/', function() use($app){
$app->render('about.twig');
});
$app->get('/contact', function() use($app){
$app->render('contact.twig');
});
$app->run();
?>
The error message is:
Fatal error: Class 'Slim\Views' not found in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\projects\simple-php-website\vendor\slim\views\Twig.php on line 46
It works without the Twig framework. So I guess the trouble is on loading the Twig. I've tried different variations of this line:
'view' => new Slim\Views\Twig()
But what confuses me is, that the error message is referring to line 46 in the Twig.php - which is in the core of slim.
I've tried reinstalling Twig and Slim several times.
Any suggestions what is wrong?
Much appreciated!
EDIT This is from my composer.json
{
"name": "tyf5vl/simple-php-website",
"authors": [
{
"name": "My Name",
"email": "my@mail.com"
}
],
"require": {
"monolog/monolog": "^1.17",
"slim/slim": "^3.1",
"twig/twig": "^1.23",
"slim/views": "^0.1.3"
}
}