Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Building Websites with PHP Slim Basics & Twig Templates Including & Rendering

Burak Tomrukcu
Burak Tomrukcu
6,402 Points

I cannot see index.html

I created templates folder and added index.html and contact.html. Altough i can reach contact.html index.html doesn't show up.

<?php

Having: error_reporting(-1); ini_set('display_errors', 'On');

require __DIR__ . '/vendor/autoload.php';
date_default_timezone_set('Europe/Istanbul');

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

//$log = new Logger('name');
//$log->pushHandler(new StreamHandler('app.txt', Logger::WARNING));
//$log->addWarning('oh, no');

$app = new\Slim\Slim();

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

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

$app->run();

Hi Burak,

I added markdown to help make the code more readable. If you're curious about how to add markdown like this on your own, checkout this thread on posting code to the forum . Also, there is a link at the bottom called Markdown Cheatsheet that gives a brief overview of how to add markdown to your posts.

Cheers!

2 Answers

Damian Saunders
Damian Saunders
23,000 Points

Hi Burak, Looks like you're missing the $ on app in your functions - should be $app->render...

Cheers Damian

Are you by any chance looking for .twig instead of .html?