It appears you're experiencing some troubles with installing msgraph-sdk-php
package and that's the reason why Model\User
type could not be resolved in your case. If you are following the official Getting Started documentation, there is a typo regarding package name in Installation section:
{
"require": {
"Microsoft/Graph": "^1.0"
}
}
and while installing you should get the error like this
The requested package microsoft/graph could not be found in any
version, there may be a typo in the package name.
Instead of Microsoft/Graph
the valid name should be microsoft/microsoft-graph
, for example:
{
"require": {
"microsoft/microsoft-graph": "^1.6"
}
}
Once the package is installed successfully, the minimal example for retrieving users could look like this:
require_once './vendor/autoload.php';
use \Microsoft\Graph\Graph;
$accessToken = "--YOUR-ACCESS-TOKEN-GOES-HERE--";
$graph = new Graph();
$graph->setAccessToken($accessToken);
$user = $graph->createRequest("GET", "/users")
->setReturnType(\Microsoft\Graph\Model\User::class)
->execute();