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

Ben Os
Ben Os
20,008 Points

I can't have the special Slim-PHP 404 error page that I should have

I took the PHP track and I do the course "Building websites with PHP" with Hampton Paulk:

https://teamtreehouse.com/library/building-websites-with-php/slim-basics-twig-templates/including-running-slim

I rewrote the relevant code Hampton showed In the second lecture (I wrote it in index.php). But, when I previewed the workspace, I didn't see the special 404 page Hampton had, but rather a code error:

" Fatal error: Uncaught Error: Class 'Slim\Slim' not found in /home/treehouse/workspace/index.php:6 Stack trace: #0 {main} thrown in /home/treehouse/workspace/index.php on line 6 "

Here is my code:

<?php

require 'vendor/autoload.php';
date_default_timezone_set('Asia/Jerusalem');

$app = new \Slim\Slim();

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

$app->run();

?>

Here is a snapshot of my code:

https://w.trhou.se/wbtrz75tzu

Here is a link to my homepage with the error:

http://port-80-4fvfqngcqw.treehouse-app.com/

Alena Holligan
Alena Holligan
Treehouse Teacher

can you try a "composer update" in the console or create a "snapshot" and share that here so we can see your code.

Ben Os
Ben Os
20,008 Points

Helo Alena, I've tried typing composer update (without any further syntax) in the console and when the update process finished I tried to fully refresh (CTRL+F5) my preview\homepage but the same error still occurs.

I've updated the question with further details in it's end.

Alena Holligan
Alena Holligan
Treehouse Teacher

Change your slim version in your composer.json file

"slim/slim": "~2.6"

Then run composer update again, and make sure you are going to the full path, like http://port-80-4fvfqngcqw.treehouse-app.com/hello/ben

Ben Os
Ben Os
20,008 Points

Worked, much thanks !!!