rcrowe / TwigBridge

Give the power of Twig to Laravel
MIT License
894 stars 168 forks source link

Extension\Laravel\Translator in Lumen #367

Open jpedryc opened 5 years ago

jpedryc commented 5 years ago

Hi

The situation: I'm currently trying to move a working Laravel app to Lumen. It's a renderer-style app which - based on a JSON - glues up twig view files with some parameters and renders the view.

Main problem: A chain of unresolved dependencies.

In README.md I can find:

For Lumen, you need to load the same Service Provider, but you have to disable the Auth, Translator and Url extensions in your local configuration.

I have a lot of twig view files where the function trans([3]) is being used, my main goal is to get that to work. First, I tried the default twig extension _Twig_Extensions_ExtensionI18n - the function is being found, however it's not the same thing = trans([1]).

Second approach was to get the Laravel extension to work by adding manually some dependencies as the errors occur, but that seems to be reinventing the wheel.

Did create a Translator based on the Illuminate\Translation\Translator and a Loader based on Illuminate\Contracts\Translation\Loader (singletons). Stopped doing that after the next one: Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager.

Do you have some ideas how to tackle this issue? Am I missing something while bootstrapping Lumen?

Thanks in advance