odan / slim4-skeleton

A Slim 4 Skeleton
https://odan.github.io/slim4-skeleton/
MIT License
439 stars 80 forks source link

Add twig-assets dependency #1

Closed killua-eu closed 5 years ago

killua-eu commented 5 years ago

Moving https://github.com/odan/twig-assets/issues/9 to this repo's issues. Quoting:

Hi Daniel, would you mind including some examples to get twig-assets work with slim4, or maybe show that in your hatching https://github.com/odan/slim4-skeleton ? Thanks lots in advance, cheers, P.

Hi @killua-eu Yes, this would be the next step for the slim4-skeleton project. I'm working on it. Would be nice if you create an issue here: https://github.com/odan/slim4-skeleton/issues Thanks.

odan commented 5 years ago

I just added the twig-assets dependency. The configuration is like before:

https://github.com/odan/slim4-skeleton/blob/master/config/container.php#L94

The only difference is the new Slim 4 RouteParser.

https://github.com/odan/slim4-skeleton/blob/master/config/container.php#L114

// Add relative base url
$routeParser = $container->get(RouteParserInterface::class);
$twig->addGlobal('base_url', $routeParser->urlFor('root'));
killua-eu commented 5 years ago

Thanks lots.