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 trialAero Camacho
Java Web Development Techdegree Student 641 PointsI keep getting a Slim Application Error.
Slim Application Error The application could not run because of the following error:
Details
Type: BadMethodCallException
Message: Method display is not a valid method
File: /home/ubuntu/workspace/vendor/slim/slim/Slim/App.php
Line: 124
Trace
#0 /home/ubuntu/workspace/index.php(11): Slim\App->__call('display', Array)
#1 /home/ubuntu/workspace/index.php(11): Slim\App->display('index.html')
#2 [internal function]: Closure->{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#3 /home/ubuntu/workspace/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#4 /home/ubuntu/workspace/vendor/slim/slim/Slim/Route.php(344): Slim\Handlers\Strategies\RequestResponse->__invoke(Object(Closure), Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#5 /home/ubuntu/workspace/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(116): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#6 /home/ubuntu/workspace/vendor/slim/slim/Slim/Route.php(316): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#7 /home/ubuntu/workspace/vendor/slim/slim/Slim/App.php(438): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#8 /home/ubuntu/workspace/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(116): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#9 /home/ubuntu/workspace/vendor/slim/slim/Slim/App.php(332): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#10 /home/ubuntu/workspace/vendor/slim/slim/Slim/App.php(293): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#11 /home/ubuntu/workspace/index.php(18): Slim\App->run()
#12 {main}
composer version is 3.7 if that helps. my code is...
<?php
require 'vendor/autoload.php';
date_default_timezone_get('Asia/Seoul');
$config = ['settings' => ['displayErrorDetails' => true]];
$app = new \Slim\App($config, array(
'templates.path' => './test-folder'
));
$app->get('/', function() use($app){
$app->display('index.html');
});
$app->get('/contact', function() use($app){
$app->render('contact.html');
});
$app->run();
help! :c
Aero Camacho
Java Web Development Techdegree Student 641 PointsAlso fixed $app->display to $app->render again sorry i'm also trying out new stuff. still doesn't work tho.
1 Answer
Chris Shaw
26,676 PointsHi Aero Camacho,
As shown on the GitHub page, you need to return
your rendered views otherwise the application won't know it has anything to render.
$app->get('/', function() use ($app) {
return $app->render('index.html');
});
$app->get('/contact', function() use ($app) {
return $app->render('contact.html');
});
Happy coding!
Aero Camacho
Java Web Development Techdegree Student 641 PointsI followed the stuff from the github page, it works perfectly now. Thanks!
Aero Camacho
Java Web Development Techdegree Student 641 PointsAero Camacho
Java Web Development Techdegree Student 641 Points<?php require 'vendor/autoload.php'; date_default_timezone_get('Asia/Seoul'); $config = ['settings' => ['displayErrorDetails' => true]];
$app->run();
Well, i removed the arrays still nothing.