How to fix this error in Slim framework? -
i installed slim framwork using composer in wamp server.
but displays following error.
i new slim.
slim application error application not run because of following error:
details
type: errorexception code: 2 message: file_get_contents(templates/index.html): failed open stream: no such file or directory file: d:\wamp\www\photometa\vendor\twig\twig\lib\twig\loader\filesystem.php line: 131 trace
0 [internal function]: slim\slim::handleerrors(2, 'file_get_conten...', 'd:\wamp\www\pho...', 131, array)
1 d:\wamp\www\photometa\vendor\twig\twig\lib\twig\loader\filesystem.php(131):
file_get_contents('templates/index...')
2 d:\wamp\www\photometa\vendor\twig\twig\lib\twig\environment.php(397):
twig_loader_filesystem->getsource('index.html')
3 d:\wamp\www\photometa\vendor\slim\views\twig.php(87): twig_environment->loadtemplate('index.html')
4 d:\wamp\www\photometa\vendor\slim\slim\slim\view.php(255): slim\views\twig->render('index.html', null)
5 d:\wamp\www\photometa\vendor\slim\slim\slim\view.php(243): slim\view->fetch('index.html', null)
6 d:\wamp\www\photometa\vendor\slim\slim\slim\slim.php(757): slim\view->display('index.html')
7 d:\wamp\www\photometa\public\index.php(33): slim\slim->render('index.html')
8 [internal function]: {closure}()
9 d:\wamp\www\photometa\vendor\slim\slim\slim\route.php(468): call_user_func_array(object(closure), array)
10 d:\wamp\www\photometa\vendor\slim\slim\slim\slim.php(1357): slim\route->dispatch()
11 d:\wamp\www\photometa\vendor\slim\slim\slim\middleware\flash.php(85):
slim\slim->call()
12 d:\wamp\www\photometa\vendor\slim\slim\slim\middleware\methodoverride.php(92):
slim\middleware\flash->call()
13 d:\wamp\www\photometa\vendor\slim\slim\slim\middleware\prettyexceptions.php(67):
slim\middleware\methodoverride->call()
14 d:\wamp\www\photometa\vendor\slim\slim\slim\slim.php(1302): slim\middleware\prettyexceptions->call()
15 d:\wamp\www\photometa\public\index.php(37): slim\slim->run()
16 {main}
this index.php
<?php require '../vendor/autoload.php'; // prepare app $app = new \slim\slim(array( 'templates.path' => '../templates', )); // create monolog logger , store logger in container singleton // (singleton resources retrieve same log resource definition each time) $app->container->singleton('log', function () { $log = new \monolog\logger('slim-skeleton'); $log->pushhandler(new \monolog\handler\streamhandler('../logs/app.log', \monolog\logger::debug)); return $log; }); // prepare view $app->view(new \slim\views\twig()); $app->view->parseroptions = array( 'charset' => 'utf-8', 'cache' => realpath('../templates/cache'), 'auto_reload' => true, 'strict_variables' => false, 'autoescape' => true ); $app->view->parserextensions = array(new \slim\views\twigextension()); // define routes $app->get('/', function () use ($app) { // sample log message $app->log->info("slim-skeleton '/' route"); // render index view $app->render('index.html'); }); // run app $app->run();
try :
$app = new \slim\slim(array( 'templates.path' => __dir__ . '/../templates/', ));
Comments
Post a Comment