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 trialDennis Aguilar
3,249 PointsI cannot view my contact.html file.
I can't properly view my contact page at the moment. Prior to entering this code,
$app->get('/contact', function() use($app){
$app->render('contact.html');
});
and prior to deleting the contact.html file in the root of the project folder, I could view the contact.html page just fine.
Now, when I click the Contact button on the About page, it displays this: "Not Found
The requested URL /Users/dennispifer/Website2/BuildingWebsiteswithPHP/index.php was not found on this server." Confusingly the URL is actually: "http://localhost/default/BuildingWebsiteswithPHP/contact.html"
When I enter the following URL, a Contact page displays without the images and resources associated with it. http://localhost/default/BuildingWebsiteswithPHP/index.php/contact
Let me reiterate that for some reason the contact page was working before I altered the
$app->get('/contact', function()
portion of the index.php file.
Here's all of my code:
<?php
require 'vendor/autoload.php';
date_default_timezone_set('America/New_York');
// use Monolog\Logger;
// use Monolog\Handler\StreamHandler;
// $log = new Logger('name');
// $log->pushHandler(new StreamHandler('app.txt', Logger::WARNING));
//$log->addWarning('Foo');
$app = new \Slim\Slim();
$app->get('/', function() use($app){
$app->render('index.html');
});
$app->get('/contact', function() use($app){
$app->render('contact.html');
});
$app->run();
1 Answer
Ted Sumner
Courses Plus Student 17,967 PointsThis is the final code for the contact reference:
<?php
$app->get('/contact', function() use($app) {
$app->render("contact.twig");
})->name('contact');
In order to really evaluate what is wrong, you need to post your entire code. Formatting really makes it easier to read and analyze any errors.
Please learn how to format your quotes in the future by reading the Markdown Cheatsheet linked below.