Felix
Felix

Reputation: 5619

php composer project class not found

Hi I try to use this composer package:

https://github.com/stevenmaguire/oauth2-microsoft

Code looks like this at the moment:

use \Stevenmaguire\OAuth2\Client\Provider\Microsoft;

$provider = new Microsoft([
    // Required
    'clientId'                  => '',
    'clientSecret'              => '',
    'redirectUri'               => 'http://localhost/microsoftToDo/app/microsoft.php',
    // Optional
    'urlAuthorize'              => 'https://login.windows.net/common/oauth2/authorize',
    'urlAccessToken'            => 'https://login.windows.net/common/oauth2/token',
    'urlResourceOwnerDetails'   => 'https://outlook.office.com/api/v1.0/me'
]);

when I run the project I got this error:

Fatal error: Uncaught Error: Class 'Stevenmaguire\OAuth2\Client\Provider\Microsoft' not found in C:\xampp\htdocs\microsoftToDo\src\microsoft.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\microsoftToDo\src\microsoft.php on line 12

Folder structure is:

enter image description here

What Is my issue in this case? thanks in advance.

Upvotes: 0

Views: 501

Answers (1)

fire
fire

Reputation: 21531

It looks like you haven't installed it properly with composer, if you had that Stevenmaguire folder would be inside a vendor folder.

From your projects root run...

composer require stevenmaguire/oauth2-microsoft

Then if you see a vendor folder it has worked. You will also need to require vendor/autoload.php in your code to autoload that class.

Upvotes: 2

Related Questions