Zend expressive - Layout
问题 In my layout (Twig), i'd like to retrieve a value from a Middleware authentication. If i put, in templates.global.pĥp: 'twig' => [ 'globals' => [ // Variables to pass to all twig templates 'auth' => (new \Zend\Authentication\AuthenticationService())->hasIdentity(), ], ], And in layout default.html.twig {% if auth %} Connect {% else %} Not connect {% endif %} This code works, but, is it a good method ? Thank you :) 回答1: It's not a good method. First of all, using the config files to set global