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 Routing in Slim

Add a 'get' route to 'index.php'

Based on the code I used (successfully) in my actual Twig page, I feel like this should work. However, I'm getting the not-so-helpful "Bummer! Try again!" message. Can anyone spot my mistake?

index.php
<?php
require 'Slim.php';

$app = new \Slim\Slim();

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

$app->run();

Just figured this one out based on another user's experience I had missed... they don't want the app->render line. A bit misleading, indeed.

3 Answers

try removing the semicolon after the $app->render line.

Thanks Ted - they didn't want that line at all, apparently, so it worked after deleting it. :)

Preston Yeschick
Preston Yeschick
10,803 Points

Removing the $app->render line worked for me too.

This code passed for me:

<?php
require 'Slim.php';

$app = new \Slim\Slim();

/*  add your code below this line */
$app->get('/hello', function() use($app){
         echo 'Hello There';
});

/* add your code above this line */

$app->run();

The first part of the challenge was to add $app->get('/hello');. The second part added the remainder of the $app->get line. I didn't have to remove anything from the code. I was just careful to add only what I was instructed to by the step of the challenge. The challenge never said to add a render line. The second step said to add an echo line.