{"id":22281506,"url":"https://github.com/microsoftgraph/msgraph-sdk-php-core","last_synced_at":"2025-04-09T13:09:31.746Z","repository":{"id":37429752,"uuid":"375747445","full_name":"microsoftgraph/msgraph-sdk-php-core","owner":"microsoftgraph","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-24T06:01:32.000Z","size":11363,"stargazers_count":12,"open_issues_count":5,"forks_count":4,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-10-25T00:26:11.617Z","etag":null,"topics":["devxeng"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoftgraph.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-10T15:34:03.000Z","updated_at":"2024-10-24T06:01:35.000Z","dependencies_parsed_at":"2023-10-13T07:51:34.741Z","dependency_job_id":"2f50024b-3302-460a-9d3c-00a4e8e5013e","html_url":"https://github.com/microsoftgraph/msgraph-sdk-php-core","commit_stats":{"total_commits":579,"total_committers":31,"mean_commits":"18.677419354838708","dds":0.7132987910189983,"last_synced_commit":"c4b1c4cf2844ca8493658ecffa771ef1c55856a4"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoftgraph%2Fmsgraph-sdk-php-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoftgraph%2Fmsgraph-sdk-php-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoftgraph%2Fmsgraph-sdk-php-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoftgraph%2Fmsgraph-sdk-php-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoftgraph","download_url":"https://codeload.github.com/microsoftgraph/msgraph-sdk-php-core/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045245,"owners_count":21038554,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["devxeng"],"created_at":"2024-12-03T16:18:45.333Z","updated_at":"2025-04-09T13:09:31.725Z","avatar_url":"https://github.com/microsoftgraph.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Get started with the Microsoft Graph Core SDK for PHP\n\n[![Latest Stable Version](https://poser.pugx.org/microsoft/microsoft-graph-core/version)](https://packagist.org/packages/microsoft/microsoft-graph-core)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=microsoftgraph_msgraph-sdk-php-core\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=microsoftgraph_msgraph-sdk-php-core)\n\n## Install the Core Library\nTo install the `microsoft-graph-core` library with Composer, either run `composer require microsoft/microsoft-graph-core`, or edit your `composer.json` file:\n```\n{\n    \"require\": {\n        // x-release-please-start-version\n        \"microsoft/microsoft-graph-core\": \"^2.3.1\"\n        // x-release-please-end\n    }\n}\n```\n## Get started with Microsoft Graph\n\n### 1. Register your application\n\nRegister your application to use the Microsoft Graph API by following the steps at [Register an application with the Microsoft Identity platform](https://aka.ms/registerApplication).\n\n### 2. Authenticate with the Microsoft Graph service\n\nThe Microsoft Graph Core SDK for PHP does not include any default authentication implementations. The [`thephpleague/oauth2-client`](https://github.com/thephpleague/oauth2-client) library will handle the OAuth2 flow for you and provide a usable token for querying the Graph.\n\nTo authenticate as an application, please see [this guide](https://docs.microsoft.com/en-us/graph/auth-v2-service?context=graph%2Fapi%2F1.0\u0026view=graph-rest-1.0) to configure the right permissions.\n\nYou can use the [Guzzle HTTP client](http://docs.guzzlephp.org/en/stable/), which comes preinstalled with this library, to get an access token like this:\n```php\n\n$tokenRequestContext = new ClientCredentialContext(\n    'tenantId',\n    'clientId',\n    'clientSecret'\n);\n// requests using https://graph.microsoft.com/.default scopes by default\n$tokenProvider = new GraphPhpLeagueAccessTokenProvider($tokenRequestContext);\n$token = $tokenProvider-\u003egetAuthorizationTokenAsync(GraphConstants::REST_ENDPOINT)-\u003ewait();\n```\n\n### 3. Create a Guzzle HTTP client object\nYou can create a Guzzle HTTP client object pre-configured for use with the Graph API using our `GraphClientFactory`. The `GraphClientFactory`\nsets some Guzzle config defaults such as connection and request timeouts, and the `base_uri` to your preferred [National Cloud endpoint](https://docs.microsoft.com/en-us/graph/deployments#microsoft-graph-and-graph-explorer-service-root-endpoints).\n\nIn the near future, the `GraphClientFactory` will provide some default middleware to use with the Graph API such as retry handlers.\n\n```php\nuse Microsoft\\Graph\\Core\\GraphClientFactory;\n\n$guzzleConfig = [\n    // your preferred guzzle config\n];\n\n$httpClient = GraphClientFactory::createWithConfig($guzzleConfig);\n```\n\n### 4. Call Microsoft Graph using the v1.0 endpoint\n\nThe following is an example that shows how to call Microsoft Graph.\n\n```php\nuse Microsoft\\Graph\\Core\\GraphClientFactory;\n\nclass UsageExample\n{\n    public function run()\n    {\n        $accessToken = 'xxx';\n\n        $config = [\n            'headers' =\u003e [\n                'Authorization' =\u003e $accessToken\n            ]\n        ];\n\n        $httpClient = GraphClientFactory::createWithConfig($config);\n        $response = $httpClient-\u003eget(\"/v1.0/me\");\n        $currentUser = json_decode($response-\u003egetBody());\n\n        echo \"Hello, I am {$currentUser['givenName']}\";\n    }\n}\n```\n\nWe provide Microsoft Graph models for easy serialization and deserialization.\n\nIf you would like to leverage the models we provide, please take a look at the [Microsoft Graph PHP SDK](https://packagist.org/packages/microsoft/microsoft-graph) and for\nbeta models - the [Microsoft Graph Beta PHP SDK](https://packagist.org/packages/microsoft/microsoft-graph-beta).\n\n## Documentation and resources\n\n* [Microsoft Graph website](https://aka.ms/graph)\n\n## Develop\n\n### Run Tests\n\nRun\n ```shell\nvendor/bin/phpunit\n```\nfrom the base directory.\n\n#### Debug tests on Windows\n\nThis SDK has an XDebug run configuration that attaches the debugger to VS Code so that you can debug tests.\n\n1. Install the [PHP Debug](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug) extension into Visual Studio Code.\n2. From the root of this repo, using PowerShell, run `php .\\tests\\GetPhpInfo.php | clip` from the repo root. This will copy PHP configuration information into the clipboard which we will use in the next step.\n3. Paste your clipboard into the [XDebug Installation Wizard](https://xdebug.org/wizard) and select **Analyse my phpinfo() output**.\n4. Follow the generated instructions for installing XDebug. Note that the `/ext` directory is located in your PHP directory.\n5. Add the following info to your php.ini file:\n\n```\n[XDebug]\nxdebug.remote_enable = 1\nxdebug.remote_autostart = 1\n```\n\nNow you can hit a Visual Studio Code breakpoint in a test. Try this:\n\n1. Add a breakpoint to `testCreateWithConfigCreatesClient` in *.\\tests\\Http\\GraphClientFactoryTest.php*.\n2. Run the **Listen for XDebug** configuration in VS Code.\n3. Run `.\\vendor\\bin\\phpunit --filter testCreateWithConfigCreatesClient` from the PowerShell terminal to run the test and hit the breakpoint.\n\n## Issues\n\nView or log issues on the [Issues](https://github.com/microsoftgraph/msgraph-sdk-php-core/issues) tab in the repo.\n\n## Contribute\n\nPlease read our [Contributing](https://github.com/microsoftgraph/msgraph-sdk-php-core/blob/main/CONTRIBUTING.md) guidelines carefully for advice on how to contribute to this repo.\n\n## Copyright and license\n\nCopyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT [license](LICENSE).\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoftgraph%2Fmsgraph-sdk-php-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoftgraph%2Fmsgraph-sdk-php-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoftgraph%2Fmsgraph-sdk-php-core/lists"}