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 trialSarut Jarumaneeroj
14,656 PointsSlim Application Error
something happen !
Slim Application Error The application could not run because of the following error:
Details
Type: RuntimeException
Message: View cannot render index.html
because the template does not exist
File: /home/treehouse/workspace/vendor/slim/slim/Slim/View.php
Line: 272
Trace
0 /home/treehouse/workspace/vendor/slim/slim/Slim/View.php(255): Slim\View->render('index.html', NULL)
1 /home/treehouse/workspace/vendor/slim/slim/Slim/View.php(243): Slim\View->fetch('index.html', NULL)
2 /home/treehouse/workspace/vendor/slim/slim/Slim/Slim.php(757): Slim\View->display('index.html')
3 /home/treehouse/workspace/index.php(13): Slim\Slim->render('index.html')
4 [internal function]: {closure}()
5 /home/treehouse/workspace/vendor/slim/slim/Slim/Route.php(468): call_user_func_array(Object(Closure), Array)
6 /home/treehouse/workspace/vendor/slim/slim/Slim/Slim.php(1357): Slim\Route->dispatch()
7 /home/treehouse/workspace/vendor/slim/slim/Slim/Middleware/Flash.php(85): Slim\Slim->call()
8 /home/treehouse/workspace/vendor/slim/slim/Slim/Middleware/MethodOverride.php(92): Slim\Middleware\Flash->call()
9 /home/treehouse/workspace/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\MethodOverride->call()
10 /home/treehouse/workspace/vendor/slim/slim/Slim/Slim.php(1302): Slim\Middleware\PrettyExceptions->call()
11 /home/treehouse/workspace/index.php(19): Slim\Slim->run()
12 {main}
anyone please help me !
So this is my code . <?php
require 'vendor/autoload.php'; date_default_timezone_set("Asia/Bangkok");
//$log = new Monolog\Logger('name'); //$log->pushHandler(new Monolog\Handler\StreamHandler('app.txt', Monolog\Logger::WARNING)); //$log->addWarning('Foo');
$app = new \Slim\Slim();
$app->get('/', function () use($app) { $app->render('index.html'); }); $app->get('/contact', function () { echo "Fell free to cantact"; });
$app->run();
2 Answers
miguelcastro2
Courses Plus Student 6,573 PointsYour app cannot find the file index.html, as indicated by the error. Make sure it is in the path that slim is looking in. On default the directory it searches for is templates, but you can set it using the templates.path setting.
thomascawthorn
22,986 PointsHave you by any chance changed the app to look for index.twig? Or home.twig? If so, replace .html with .twig