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 trialJonathan Grieve
Treehouse Moderator 91,253 PointsPosting of form returns as "Object Not Found" on localhost
It never seems to go right for me on this course. :D Tried to fix this on my own but I'm not sure what to do.
I submit the form on localhost/composer/contact
and I get this,
Object not found!
The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12
Here's my index.php file.
<?php
//require autoload to include all of composers libraries
require "vendor/autoload.php";
// use London time to log errors and warnings
date_default_timezone_set("Europe/London");
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
//create a new instance of monolog
//$log = new Logger('name'); //new monolog logger instance
//$log->pushHandler(new StreamHandler('app.txt', Logger::WARNING)); //use object object operator
//$log->addWarning('Warning: ');
$app = new \Slim\Slim(array(
'view' => new \Slim\Views\Twig() // set view to be the Twig class
)); //new slim object instance
$view = $app->view();
$view->parserOptions = array(
'debug' => true //set debug to true
);
$view->parserExtensions = array(
new \Slim\Views\TwigExtension(), //helpers
);
/*object behaviours*/
$app->get('/', function() use ($app) {
$app->render('about.twig');
})->name('home');
$app->get('/contact', function() use ($app) {
$app->render('contact.twig');
})->name('contact');/**/
$app->post('/contact', function() use ($app) {
$name = $app->request->post('name');
$email = $app->request->post('email');
$msg = $app->request->post('msg');
if(!empty($name) && !empty($email) && !empty($msg)){
} else {
//message the user that there was a problem
$app->redirect('/contact');
}
});
//Run the slim application
$app->run();
//echo "Hello, World!";
?>
I'm on localhost. But I've submitted my latest work of my Repo.
William Gertler
12,061 PointsWilliam Gertler
12,061 PointsTry deleting the; use Monolog\Logger; use Monolog\Handler\StreamHandler;
Noticed it wasn't present in the teachers code