davispeixoto / Laravel-5-Salesforce

Laravel 5 wrapper for Salesforce Force.com Toolkit SOAP API
MIT License
47 stars 36 forks source link

Usage without Facade #27

Closed nicklee1990 closed 7 years ago

nicklee1990 commented 7 years ago

Do you have an example of using this without using a facade? I usually avoid using facades in favour of dependency injection as it makes unit testing a bit easier, so I was wondering how I can allow the service container to inject the Salesforce object?

I tried injecting Davispeixoto\Laravel5Salesforce\Salesforce and however it throws an error "Call to a member function __setSoapHeaders() on null" from davispeixoto/force-dot-com-toolkit-for-php/src/Davispeixoto/ForceDotComToolkitForPhp/SforceBaseClient.php line 235

nicklee1990 commented 7 years ago

I achieved this by injecting Davispeixoto\Laravel5Salesforce\Salesforce and adding $this->app->alias('salesforce', Salesforce::class); in my Service Provider boot method

davispeixoto commented 7 years ago

Thx for sharing, @nicklee1990