mercredi 25 janvier 2017

Why I can't find the "App\Extensions\RiakUserProvider" namespace in my Laravel project following this "Adding a custom provider" tutorial?

I am absolutly new in PHP and Laravel.

I am working on a Laravel 5.3 application and I have to use a custom web service to check the user credential so I am trying to follow this official tutorial about Adding a custom provider to handle user access: http://ift.tt/2jpH12I

So, in theory it seems pretty simple but I am finding some difficulties...

As you can see in the previous tutorial as first step it modify the App\Providers\AuthServiceProvider class contained into the Laravel project.

So, I have modified my AuthServiceProvider according to the tutorial example obtaining this:

<?php

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

use Illuminate\Support\Facades\Auth;
use App\Extensions\RiakUserProvider;
use Illuminate\Support\ServiceProvider;

class AuthServiceProvider extends ServiceProvider
{
    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();

        // CUSTOM CODE:
        Auth::provider('riak', function ($app, array $config) {
            // Return an instance of Illuminate\Contracts\Auth\UserProvider...

            return new RiakUserProvider($app->make('riak.connection'));
        });
    }
}

The problem is that it can't find the App\Extension namespace, this:

use App\Extensions\RiakUserProvider;

PhpStorm signs Exstensions in red saying "Undefined Extensions namespace" so it can't use the RiakUserProvider class in my code.

Why? Have I to add some dependency in Composer? What is wrong? What am I missing? How can I fix this issue?

What exactly is the RiakUserProvider class?

What exactly does this code:

Auth::provider('riak', function ($app, array $config) {
    // Return an instance of Illuminate\Contracts\Auth\UserProvider...

    return new RiakUserProvider($app->make('riak.connection'));
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire