1
I’m developing a simple website, with Slim Framework and Twig for template engine, only that is returning the error 500 in the browser, this is the content of my file index.php
(at the root of the project):
require_once './vendor/autoload.php';
// Create container
$container = new \Slim\Container;
// Register component on container
$container['view'] = function ($c) {
$view = new \Slim\Views\Twig('app/views', [
'cache' => 'app/storage/cache'
]);
$view->addExtension(new \Slim\Views\TwigExtension(
$c['router'],
$c['request']->getUri()
));
return $view;
};
// Create app
$app = new \Slim\App($container);
// Routes
$app->get('/', function() use ($app) {
$app->render('index.twig', ['app' => $app]);
})->name('home');
// Run app
$app->run();
my folder structure is like this:
app
|__views
|__storage
|__cache
vendor
|__twig
|__slim
|__psr
|__composer
assets
|__css
|__js
|__img
|__fonts
I followed the instructions in this example:ttp://www.slimframework.com/Docs/Features/templates.html
I’d like to render the view "home", but just returns:
Error 500
In the main file put,
ini_set('display_errors', true); error_reporting(E_ALL);
– rray
I checked the apache log and this written this:
Class 'Slim\\Container' not found
– user3632930
How is your . htaccess file? Error may be in it.
– Yure Pereira
is without . htaccess
– user3632930