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

Shilpa Kothari
Shilpa Kothari
4,518 Points

how to have the get route echo 'hello world'

have the get route echo 'hello world'

<?php require 'Slim.php';

$app = new \Slim\Slim();

$app->get('/', function() { echo "Hello There"; });

$app->run();

please tell me what is wrong.

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

$app = new \Slim\Slim();

$app->get('Hello/', function() { 
  echo "Hello There";
});

$app->run();

2 Answers

I ran your code and got this error:

Bummer! is your first argument '/hello'?

It tells you that your first argument should be /hello, not Hello/. Fix that and you pass the first part of the challenge. The second part is actually the echo "Hello There" line you already have.

By the way, welcome to Treehouse. You might find this course frustrating if you are not knowledgeable about PHP. If you are, great and enjoy. Otherwise, you may find the PHP Development track a good basis for understanding the Slim course work. I know that I would have have understood that course without having first taken the PHP track.