Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Building Websites with PHP Slim Basics & Twig Templates Layouts with Twig

Slim Application Error A website error has occurred. Sorry for the temporary inconvenience.

hi guys! i need some help please i just create template using twig i cannot view its showing Application error i am using latest version of slim here's my code

$app = new \Slim\App();

// Get container
$container = $app->getContainer();

// Register component on container
$container['view'] = function ($container) {
    $view = new \Slim\Views\Twig('templates', [
        'cache' => 'path/to/cache'
    ]);
    $view->addExtension(new \Slim\Views\TwigExtension(
        $container['router'],
        $container['request']->getUri()
    ));

    return $view;
};

// Render Twig template in route
$app->get('/', function ($request, $response, $args)use($app) {
    return $this->view->render($response, 'about.twig'
    );
});

I've follow the tutorial but it's out of dated the structure of code was update need to read more to come up to the latest version

Devin Gray
Devin Gray
39,261 Points

Yes, the content is outdated since slim v3 came out. Instead of using the code in the video, use the code mentioned here in the v3 update

http://www.slimframework.com/docs/tutorial/first-app.html

When you change the code to follow that, it should at the very least show a different error if not work completely. Also make sure that you have your configuration settings set to display error details, and change your cache to equal false. If you can't find these settings in the link provided or it's still not working let me know...after I get my sleep because I just spent 3 hours fixing this problem and I was feeling generous about paying it forward. :)

thanks men just to remove the cache it work's fine now thank's a lot