mercredi 24 février 2016

How to use custom Service Providers in Laravel 5.2

I am creating a Laravel app that needs to communicate with a remote (in-house) service via API.

This API needs to be authenticated at least once per session, and after that other calls can work fine.

I think the best way is to use Laravel's service providers to do this, but I'm open to other solutions.

What I would like:

What I would like is a way to have this Service available for use whenever. I don't want to have to put the service in the parameters of a controller's method if I can avoid it. Something like this:

use MyServiceProvider;

class SomeController extends Controller 
{
    public function someMethod ()
    {
        MyServiceProvider::method();
    }
}

I can post what I've started doing thus far, if needed - but I'd rather focus on doing what I want rather than fixing what I did wrong.

inb4: I did read the docs.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire