matthiasnoback / microsoft-translator

PHP library for making calls to the Microsoft Translator V3 API
MIT License
39 stars 26 forks source link

Laravel 8 #24

Closed sheinfeld closed 4 years ago

sheinfeld commented 4 years ago

Hi there,

Could you add support to Laravel 8?

Thank you!

arraintxo commented 4 years ago

Did you have any trouble with it? This is a framework agnostic package, so it should be compatible with Laravel 8.

If what you want is a Laravel package, it isn't this libraries purpose to provide such functionality. But it shouldn't be too difficult to create a package on your own if you really need this.

Personally I would register/initialize the MicrosoftTranslator in the AppServiceProvider to be able to inject it anywhere in my app, without any need of additional packages. That's basically what the package would do.

Something similar to this should work (didn't test it). You could have the azureKey inside config/translator.php

// AppServiceProvider.php
public function register()
{
         $this->app->singleton(MicrosoftTranslator::class, function ($app) {
                  $browser = new Browser();
                  $azureKey = config('translator.azureKey');
                  $accessTokenProvider = new AzureTokenProvider($browser, $azureKey);
                  $translator = new MicrosoftTranslator($browser, $accessTokenProvider);
        });
}
sheinfeld commented 4 years ago

Hi @arraintxo,

I just realised that apologies...

My problem is actually when I add it to composer, it seams it uses outdated libraries and It just rollback :(

Anyways, great job with the package, thank you!

arraintxo commented 4 years ago

I guess we should update some library dependencies then. Thanks for your feedback, I will take a look as soon as possible.