Skip to content
New issue

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

slimphp/Twig-View Beta add global in slim4 #150

Closed
FvsJ101 opened this issue Sep 20, 2019 · 1 comment
Closed

slimphp/Twig-View Beta add global in slim4 #150

FvsJ101 opened this issue Sep 20, 2019 · 1 comment

Comments

@FvsJ101
Copy link

FvsJ101 commented Sep 20, 2019

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}

@odan
Copy link
Contributor

odan commented Nov 18, 2019

This issue has been discussed (and solved?) here: https://discourse.slimframework.com/t/slim-4-twig-globals/3464/9

@FvsJ101 FvsJ101 closed this as completed Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants