{"id":10985,"date":"2022-07-06T08:00:03","date_gmt":"2022-07-06T15:00:03","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/?p=10985"},"modified":"2023-02-03T12:14:01","modified_gmt":"2023-02-03T20:14:01","slug":"microsoft-graph-php-sdk-2-0-0-rc5-is-now-available","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/microsoft-graph-php-sdk-2-0-0-rc5-is-now-available\/","title":{"rendered":"Microsoft Graph PHP SDK 2.0.0-RC5 is now available"},"content":{"rendered":"<p>In Microsoft Graph we believe in the power of the developer community to drive innovation and growth. In this journey, we have enabled access to Microsoft Graph across many different programming languages. Given that PHP is used by roughly 80% of the web, we are pleased to announce that PHP developers can now integrate their applications with Microsoft Graph and access Microsoft services data from both beta and v1 endpoints, with enhanced programmability experience, using the new Microsoft Graph PHP SDK.<\/p>\n<p>Now available in public preview, the Microsoft Graph PHP SDK 2.0.0-RC5 is the first <a href=\"https:\/\/microsoft.github.io\/kiota\/\">Kiota<\/a> generated SDK for PHP. This new release introduces its own authentication provider that automatically refreshes access tokens, a built-in retry handler that understands response status codes and a fluent request building pattern to improve efficiency and discoverability.\u00a0This new version also resolves most of the bugs encountered in v1.<\/p>\n<h2>Authentication provider<\/h2>\n<p>Aligned with the efforts of standardization across Microsoft Graph SDKs, the new authentication provider handles the fetching, caching, and refreshing of tokens automatically. This ensures all of your requests are always authenticated. The auth provider makes sure the token is always valid by tracking the expiration and automatically refreshing it in the background before it expires.<\/p>\n<p>https:\/\/gist.github.com\/isvargasmsft\/12795cf818f0c4a80746804ff44d25b1<\/p>\n<p>The authentication provider wraps around PHP League&#8217;s\u00a0<a href=\"https:\/\/oauth2-client.thephpleague.com\/\">OAuth 2.0 client<\/a>, hence, its name \u2013 `PhpLeagueAuthenticationProvider`.<\/p>\n<p>The authentication provider supports the following flows:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/develop\/v2-oauth2-auth-code-flow\">OAuth 2.0 auth code grant<\/a> for delegated permissions.<\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/develop\/v2-oauth2-client-creds-grant-flow\">OAuth 2.0 client credentials grant<\/a> for application permissions.<\/li>\n<\/ul>\n<p>It also supports <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/active-directory\/develop\/v2-oauth2-on-behalf-of-flow\">OAuth 2.0 on-behalf-of flow<\/a> to request tokens on behalf of third-party applications.<\/p>\n<h2>Fluent request builder pattern<\/h2>\n<p>The fluent pattern makes the request building experience more intuitive. Rather than passing raw URLs, this new version provides a fluent experience to enhance discoverability and efficiency, while reducing the time spent in reference docs.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2022\/06\/Graph-PHP-SDK.png\"><img decoding=\"async\" class=\"alignnone size-full wp-image-10989\" src=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2022\/06\/Graph-PHP-SDK.png\" alt=\"Image Graph PHP SDK\" width=\"624\" height=\"143\" srcset=\"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2022\/06\/Graph-PHP-SDK.png 624w, https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-content\/uploads\/sites\/73\/2022\/06\/Graph-PHP-SDK-300x69.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>https:\/\/gist.github.com\/isvargasmsft\/fb768299ac9e2121a359290c404c3e4e<\/p>\n<h2 class=\"prettyprint\"><span style=\"color: inherit; font-family: inherit; font-size: 3rem;\">Built-in retry handler<\/span><\/h2>\n<p>A configurable built-in retry handler understands 429, 503 and 504 response status codes, reading the information in the `Retry-After` header and taking decisions accordingly. The handler reads the recommendation for throttling status codes in the `Retry-After` header and retries after the recommended time.<\/p>\n<p>See an <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-php\/blob\/feat\/kiota-preview\/docs\/Examples.md#customizing-middleware-configuration\" target=\"_blank\" rel=\"noopener\">example<\/a>\u00a0on how to customize middleware.<\/p>\n<h2>Get started<\/h2>\n<p>Get started now with the <a href=\"https:\/\/aka.ms\/graph\/sdk\/php\/preview\/upgrade\">Upgrade guide<\/a>, the <a href=\"https:\/\/aka.ms\/graph\/sdk\/php\/preview\/readme\">README<\/a> and <a href=\"https:\/\/aka.ms\/graph\/sdk\/php\/preview\/examples\">code samples<\/a>. We have written a detailed description of the breaking changes introduced by this new version. You can also find the packages for the beta endpoint <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-beta-sdk-php\/tree\/feat\/kiota-preview\">here<\/a>.<\/p>\n<p>Please don\u2019t hesitate to <a href=\"https:\/\/github.com\/microsoftgraph\/msgraph-sdk-php\/issues\/new\/\">open an issue<\/a> in our repository for any errors or breaking changes you encounter that we didn\u2019t include in our guide.<\/p>\n<p>Happy coding!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are pleased to announce that PHP developers can now integrate their applications with Microsoft Graph. And, using the new Microsoft Graph PHP SDK, developers can also now access Microsoft services data from both beta and v1 endpoints with enhanced programmability experience.<\/p>\n","protected":false},"author":95132,"featured_media":10994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[174,180],"class_list":["post-10985","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-graph","tag-kiota","tag-microsoft-graph-php-sdk"],"acf":[],"blog_post_summary":"<p>We are pleased to announce that PHP developers can now integrate their applications with Microsoft Graph. And, using the new Microsoft Graph PHP SDK, developers can also now access Microsoft services data from both beta and v1 endpoints with enhanced programmability experience.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/10985","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/95132"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=10985"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/10985\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/10994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=10985"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=10985"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=10985"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}