View in Micro framework

I am trying to use views with a Micro app.

$app['view'] = function() { $view = new \Phalcon\Mvc\View(); $view->setViewDir('../app/views/'); $view->registerEngines(array( ".phtml" => 'Phalcon\Mvc\View\Engine\Volt' )); return $view; }

$app->get('/listing/{slug}', function($slug) use ($app) { echo $app['view']->render('listing_default', array( "slug" => $slug)); });

yields nothing. I have tried using the Simple view and made many changes that render nothing. The other routes I have all work fine when I simply echo content. Are there any examples of using views with Micro besides the main docs? I have copied/pasted the main Micro docs page and it still does not work for me.




Should be setViewsDir

What directory do you have your listing_default view in?

Like Victor said, use


instead of


but also docs are not accurate, when you are using

 $view = new \Phalcon\Mvc\View();

you don't have

 public string render (string $path, [array $params])


 public Phalcon\Mvc\View render (string $controllerName, string $actionName, [array $params])

so instead of

 $app['view']->render('products/show', array());


 $app['view']->render('products', 'show', array()); they are telling about Phalcon\Mvc\View\Simple, but in code Phalcon\Mvc\View is used, althought I haven't found method to send params into view

Ok, I got it! Instead of



 echo $app['view']->getRender(string $controllerName, string $actionName, [array $params]);

Thanks for the follow up. I will have to look at Phalcon again. I gave up and moved to Silex. Primarily b/c the documentation was off just a bit and I am not "seasoned" enough to determine some solutions. Silex is much slower, but I can open php files and see code worse case scenario. I do think Phalcon is a great framework! I simply might not be savvy enough for it at this point.


Try the simple view component, maybe it works as you expect: