- What is microsoft/kiota-http-guzzle used for in Laravel?
- It provides the Guzzle-based HTTP transport that Kiota-generated PHP SDKs use to call API endpoints. In a Laravel app, you register the KiotaHttpClient and pass it to generated clients such as Microsoft Graph or Azure API SDKs. The adapter handles request sending, middleware, authentication hooks, and Kiota-specific error handling.
- How do I install microsoft/kiota-http-guzzle in a Laravel app?
- Install it with Composer by running composer require microsoft/kiota-http-guzzle; the current v2 line is typically required as ^2.0. Then bind Microsoft\Kiota\Http\KiotaHttpClient in a service provider or resolve it from the container. No Laravel package auto-discovery is needed because this is a framework-agnostic HTTP adapter.
- Does it work with Laravel's HTTP client or Guzzle?
- It is built on Guzzle, so it fits alongside Laravel's existing Guzzle dependency rather than replacing Laravel's Http facade. You can inject a configured GuzzleHttp\Client into KiotaHttpClient to share base options, handlers, and proxies. Laravel's Http::fake and HTTP middleware do not automatically apply to Kiota's Guzzle pipeline, so configure and test that pipeline directly.
- Which PHP and Laravel versions are supported?
- Version 2.x of microsoft/kiota-http-guzzle requires PHP 8.2 or newer. The package is framework-agnostic, so Laravel support depends on your Laravel version running on PHP 8.2+; Laravel 11+ is a natural fit. If your app is stuck on PHP 8.1, you need an older pre-v2 Kiota adapter or a PHP upgrade.
- How do I register KiotaHttpClient in a Laravel service provider?
- Create a service provider and register a singleton for Microsoft\Kiota\Http\KiotaHttpClient, constructing it with a Guzzle client. You can then type-hint KiotaHttpClient in controllers, jobs, or generated SDK factories. Keep Guzzle options such as timeouts and proxies in config so the binding stays environment-specific.
- Can I use it without Kiota-generated clients?
- It is designed primarily as the HTTP adapter for Kiota-generated SDKs, so its main value appears when you use those clients. You can reuse its middleware concepts for custom Guzzle pipelines, but for ordinary Laravel API calls the built-in HTTP client is usually simpler. If you are not using Kiota, evaluate the overhead before adopting it.
- How does authentication work with Kiota-generated clients in Laravel?
- Kiota-generated clients expect an authentication provider, and the HTTP adapter applies that provider as requests pass through the pipeline. In Laravel, keep credentials in config or .env and construct the provider in a service provider rather than hard-coding tokens. For Microsoft Graph or Azure APIs, use the appropriate Kiota Azure identity authentication provider.
- How should I handle ApiException errors from Kiota in Laravel?
- Catch Kiota's ApiException types around calls to generated clients, or let them reach Laravel's exception handler and add custom rendering/reporting logic. Map API status codes to your app's HTTP responses and avoid exposing tokens or raw API payloads. Centralizing this in a service or handler keeps controllers clean.
- How do I test Kiota HTTP requests in a Laravel application?
- Use Guzzle's MockHandler and HandlerStack to queue fake responses, then inject that Guzzle client into KiotaHttpClient. Bind the mocked adapter or generated client in Laravel's container so tests do not make real network calls. Laravel's Http::fake targets Laravel's HTTP client, so it will not automatically intercept Kiota's Guzzle transport.
- Is microsoft/kiota-http-guzzle production-ready and maintained, and what alternatives exist?
- It is a Microsoft-maintained adapter intended for production use with Kiota-generated PHP clients, provided your app meets the PHP 8.2+ requirement. Releases are published from this repository, while issues and pull requests are handled in the kiota-php repository. For non-Kiota workloads, Laravel's HTTP client or a plain Guzzle setup is usually the better alternative.