We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maybe someone can advise me,
I'm using Twig view beta in the new slim 4 frame work. Im also using the slim/flash package to add messages.
Now the problem is I want to create a new global so that my twig view can use the message but i keep getting the below error...
$this->container->get("view")->getEnvironment()->addGlobal('flash', $_SESSION['slimFlash']);
Unable to add global "flash" as the runtime or the extensions have already been initialized.
Can anyone advise on how to get around this or the fix for this?
#0 C:\wamp\www\slim4starter\app\Middleware\CsrfViewMiddleware.php(23): Twig\Environment->addGlobal('here', 'there') #1 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(212): App\Middleware\CsrfViewMiddleware->__invoke(Object(Slim\Psr7\Request), Object(class@anonymous)) #2 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(58): class@anonymous->handle(Object(Slim\Psr7\Request)) #3 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #4 C:\wamp\www\slim4starter\vendor\slim\twig-view\src\TwigMiddleware.php(108): class@anonymous->handle(Object(Slim\Psr7\Request)) #5 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Views\TwigMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #6 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(89): class@anonymous->handle(Object(Slim\Psr7\Request)) #7 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous)) #8 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(64): class@anonymous->handle(Object(Slim\Psr7\Request)) #9 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\App.php(174): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request)) #10 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\App.php(158): Slim\App->handle(Object(Slim\Psr7\Request)) #11 C:\wamp\www\slim4starter\public\index.php(6): Slim\App->run() #12 {main}
The text was updated successfully, but these errors were encountered:
This issue has been discussed (and solved?) here: https://discourse.slimframework.com/t/slim-4-twig-globals/3464/9
Sorry, something went wrong.
No branches or pull requests
Maybe someone can advise me,
I'm using Twig view beta in the new slim 4 frame work. Im also using the slim/flash package to add messages.
Now the problem is I want to create a new global so that my twig view can use the message but i keep getting the below error...
$this->container->get("view")->getEnvironment()->addGlobal('flash', $_SESSION['slimFlash']);
Unable to add global "flash" as the runtime or the extensions have already been initialized.
Can anyone advise on how to get around this or the fix for this?
#0 C:\wamp\www\slim4starter\app\Middleware\CsrfViewMiddleware.php(23): Twig\Environment->addGlobal('here', 'there')
#1 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(212): App\Middleware\CsrfViewMiddleware->__invoke(Object(Slim\Psr7\Request), Object(class@anonymous))
#2 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\Middleware\RoutingMiddleware.php(58): class@anonymous->handle(Object(Slim\Psr7\Request))
#3 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous))
#4 C:\wamp\www\slim4starter\vendor\slim\twig-view\src\TwigMiddleware.php(108): class@anonymous->handle(Object(Slim\Psr7\Request))
#5 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Views\TwigMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous))
#6 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\Middleware\ErrorMiddleware.php(89): class@anonymous->handle(Object(Slim\Psr7\Request))
#7 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(123): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class@anonymous))
#8 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\MiddlewareDispatcher.php(64): class@anonymous->handle(Object(Slim\Psr7\Request))
#9 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\App.php(174): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request))
#10 C:\wamp\www\slim4starter\vendor\slim\slim\Slim\App.php(158): Slim\App->handle(Object(Slim\Psr7\Request))
#11 C:\wamp\www\slim4starter\public\index.php(6): Slim\App->run()
#12 {main}
The text was updated successfully, but these errors were encountered: