View related to action not picked


I have a small problem (I can do what I want with another way, but it's weird) I have a SessionController


namespace App\Controllers;

class SessionController extends ControllerBase {

public function initialize()

public function loginAction()

// Shows only the view related to the action $this->view->pick('session/login'); }

A route /login in my router

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

And a 'login.phtml' view inside a 'session' folder. And the problem is, my login.phtml is not picked with $this->view->pick('session/login'); and I really can't know why.

Hi @etshy two things

one: $this->view->pick('session/login'); you are using "login" is the same action name

two: do you have set right the view service?

edited Oct '17

I don't change the view services definition from the create-project

$di->setShared('view', function () { $config = $this->getConfig();

$view = new View();

    '.volt' => function ($view) {
        $config = $this->getConfig();

        $volt = new VoltEngine($view, $this);

            'compiledPath' => $config->application->cacheDir,
            'compiledSeparator' => '_'

        return $volt;
    '.phtml' => PhpEngine::class


return $view;


with the viewsDir

'viewsDir' => APP_PATH . '/views/',

So I have my view in APP_PATH/viewssession/login.phtml

So, normally, It take my main view in views/index.phtml, a templateBefore views/layouts/session.phtml and my action view in /views/session/login.phtml

but it doesn't works.

I know I pick the same action name as template, but that's the problem. The view is not picked if I don't do it explicitly.

Don't understant because it works great on my IndexController and my indexAction. in views/layout/index.phtml and views/index/index.html