We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Volt does not show nothing when I acces only with domain.com

I have and app using volt template Engine, When I access using only the url as domain name (domain.com) it doesnt show the index page, I need to add the domain.com/index to show it: here is my view dependecy injector service:

$di->set('view', function() use ($config) {
        $view = new View();
        $view->setViewsDir(__DIR__.$config->myapp->viewsDir);
        $view->registerEngines(array(
            '.volt' => function($view, $di) use ($config) {
                $volt = new Volt($view, $di);
                $volt->setOptions(array(
                    'compiledPath' => __DIR__.$config->myapp->cacheDir,
                    'compiledSeparator' => '_',
                    'stat' => true,
                    'compileAlways' => true
                ));
                return $volt;
            },
            '.phtml' => '\Phalcon\Mvc\View\Engine\Php'
        ));
        return $view;
    }, true);

and my views folder is listing like:

views
    ->about
        ->index.volt
    ->index
        ->index.volt
    ->index.volt

In the main index.volt I have {{ content() }}. What Im missing?

You might have a route problem. Create a route for '/'

 $router->add('/', [
        'controller' => 'index',
        'action' => 'index'
 ]);

Definately a router problem... You could either add the route mentioned by @StefanChiriac, or in you router service setDefaultController('index') and setDefaultAction('index')

edited Oct '15

Yeah!! my problem was in the router service, but not by the errors you mentioned before, I had this code:

$router->setDefaults([
            "controller" => "Index",
            "action" => "index"
        ]);

For some reason the router it wasnt reading the Capital letter on ("controller" => "Index") I change it for ("controller" => "index") and its works now. Thank you any way!!

by default, in phalcon, when you specify the controller or action has to start with small letter :)

Thank you Stefan!! i'm a beginner with phalcon :)