July 6th, 2022

Microsoft Graph PHP SDK 2.0.0-RC5 is now available

Isaac Vargas Chacon
Product Manager

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.

Now available in public preview, the Microsoft Graph PHP SDK 2.0.0-RC5 is the first Kiota 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. This new version also resolves most of the bugs encountered in v1.

Authentication provider

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.

https://gist.github.com/isvargasmsft/12795cf818f0c4a80746804ff44d25b1

The authentication provider wraps around PHP League’s OAuth 2.0 client, hence, its name – `PhpLeagueAuthenticationProvider`.

The authentication provider supports the following flows:

It also supports OAuth 2.0 on-behalf-of flow to request tokens on behalf of third-party applications.

Fluent request builder pattern

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.

Image Graph PHP SDK

https://gist.github.com/isvargasmsft/fb768299ac9e2121a359290c404c3e4e

Built-in retry handler

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.

See an example on how to customize middleware.

Get started

Get started now with the Upgrade guide, the README and code samples. 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 here.

Please don’t hesitate to open an issue in our repository for any errors or breaking changes you encounter that we didn’t include in our guide.

Happy coding!

Author

Isaac Vargas Chacon
Product Manager

0 comments

Discussion are closed.