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

Robbie Thomas
Robbie Thomas
31,093 Points

Challenge 1 of 2

What am I doing wrong?

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

$app = new \Slim\Slim();

/*  add your code below this line */
$app->get('/hello', function() use($app){
  $app->render('index.php')
};

/* add your code above this line */

$app->run();

6 Answers

Richard, you are still misssing the ) for the $app->get(. It should be:

<?php
$app->get('/hello', function() use($app){ echo 'Hello There'; });
// Notice the ) after the } and before the ;
Richard Cain
Richard Cain
Courses Plus Student 9,029 Points

Yeah, I missed that when I copied his code over to the comment. It's fixed now, thanks.

you open the parenthesis for the get but you do not close them. You need to close it like this });

I'm not hot on php but at a glance your first function has no curly braces? or comma if not containing use? so i'd say the problem lies around that line, the get has open parenthesis too?

Richard Cain
PLUS
Richard Cain
Courses Plus Student 9,029 Points

<?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

Richard Cain
Richard Cain
Courses Plus Student 9,029 Points

Replace this part: $app->render('index.php') With this: echo 'Hello There';

Robbie Thomas
Robbie Thomas
31,093 Points

Thanks for the help. I got to get a little better at this.

one of the key aspects of coding is attention to those little details. A good text editor can really help. They can be setup so if you open a (, {, or[ they will close it for you as well. I really like it.

Robbie Thomas
Robbie Thomas
31,093 Points

I got Sublime Text, but I have been using the Treehouse editor for this PHP Dev class.