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 trialRichard Lake
20,462 Pointsworkspaces / htaccess / page not found
Okay I have copied the .htaccess file from the teacher's notes as described, used '$app = new \Slim\App();' to instantiate an object. Appended /hello/richard to the address line upon previewing the code and yet... still I continue to see the Page Not Found message.
3 Answers
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsThe problem might be because Slim has been updated after the course was made. Try check out the Slim Framework website for more information :-)
https://www.slimframework.com/
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
Richard Lake
20,462 PointsThanks, thats it. I overwrote my code with yours above and it works well. I do notice that also it says {name} as opposed to :name in the get method of the app object so that makes a big difference too.
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsYou are going to use the Slim Frameworks website a lot through this course since there's been some changes to Slim since this course was published :-)
Richard Lake
20,462 PointsCorrect. And with that in mind I have decided that the best course of action is to uninstall and install v2.6 instead through composer for the purpose of completing the course.
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsThat's an option if you know you wont be using Slim after you finish the course - otherwise I would recommend taking the extra time to learn the updated version on your way through the course since you would have to learn it afterwards anyway :-)
Happy Coding! :-D
Richard Lake
20,462 PointsRichard Lake
20,462 Points