I am using OAuth laravel repo, I set it up correctly but when trying to import a class for credentials, I run into 'class not found' error.
I have a function:
'grant_types' => [
'password' => [
'callback' => '\App\PasswordVerifier@verify',
]
]
My directory looks like this:
app
--PasswordVerifier.php
config
--oauth.php (above chunk)
However, I am getting error:
ReflectionException in Container.php line 737: Class \App\PasswordVerifier does not exist
PasswordVerifier.php looks like this:
// namespace App\PasswordVerifier; - I tried with/without adding this line
use Illuminate\Support\Facades\Auth;
class PasswordVerifier
{
public function verify($username, $password)
{
...
Note that changing 'callback' => '\App\PasswordVerifier@verify
is resulting in change in the name of class in the error log.
The PasswordVerifier
class needs to be in the App
namespace:
<?php
namespace App;
use Illuminate\Support\Facades\Auth;
class PasswordVerifier
{
public function verify($username, $password)
{
...
Think of the namespaces like folders (and actually, as far as the autoloader is concerned, they're the same).
The way the Autoloader works is that when you call a class, it will use the namespace as the folder tree, and the class name as the filename.
Everything should be case sensitive except for the base app
folder, because the autoloader has been explicitly told to find anything in the App
namespace in the app
folder.