Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Okafor Matthew
Courses Plus Student 2,633 Pointsinclude and rendering
Help Please, i don't know what i have done wrong, i followed the teacher's instruction then after i render an html file i got an error such as Slim Application Error
The application could not run because of the following error:
Details
Type: RuntimeException
Message: View cannot render template/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('template/index....', NULL)
1 /home/treehouse/workspace/vendor/slim/slim/Slim/View.php(243): Slim\View->fetch('template/index....', NULL)
2 /home/treehouse/workspace/vendor/slim/slim/Slim/Slim.php(755): Slim\View->display('template/index....')
3 /home/treehouse/workspace/index.php(10): Slim\Slim->render('template/index....')
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(1355): 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(1300): Slim\Middleware\PrettyExceptions->call()
11 /home/treehouse/workspace/index.php(17): Slim\Slim->run()
12 {main}
1 Answer

Aleksandr Antropov
6,458 PointsIf you want to use slim v3:
- Install slim/php-view
- Your code should look like this:
use \Psr\Http\Message\ServerRequestInterface as Request; use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php'; date_default_timezone_set ('Europe/Moscow');
$app = new \Slim\App;
$container = $app->getContainer(); $container['view'] = new \Slim\Views\PhpRenderer('templates');
$app->get('/', function(Request $req, Response $res, $args = []) { $res= $this->view->render($res, 'index.html'); return $res; });
$app->get('/contact', function(Request $req, Response $res, $args = []) { $res= $this->view->render($res, 'contact.html'); return $res; });
$app->run();
Darrell Conklin
21,786 PointsDarrell Conklin
21,786 PointsIf you followed along with the teacher when he installed slim using composer then you are no doubt using a different version of Slim then the teacher since it has been updated.
In order to follow along with this video I recommend switching to the 2.6.3 version. Simply go your composer.json file and and change the version of slim to:
Then open your console and type
composer update
That should update slim to a similar version of what the teacher is using.
You should now be able to follow along with the teacher.