- Can I use this package with Laravel’s built-in HTTP client (Guzzle) for non-Kiota APIs?
- No, this package is *only* for Kiota-generated PHP clients. Laravel’s HTTP client (Guzzle) uses a different architecture, so you’d need to rewrite your API calls to use Kiota first. If you’re not already using Kiota, this package won’t work without significant refactoring.
- What Laravel versions does this package support?
- This package itself has no direct Laravel version requirements—it’s a Kiota dependency. However, Kiota-generated clients (e.g., Microsoft Graph SDKs) typically work with Laravel 8+ due to PHP 8.x dependencies. Always check the Kiota PHP repo for compatibility notes.
- How do I configure this serializer for a Kiota client in Laravel?
- After installing via Composer, initialize a `TextSerializationWriter` in your Kiota client’s `RequestInformation`. Example: `$writer = new TextSerializationWriter(); $requestInfo = new RequestInformation(new Uri('https://api.example.com'), 'POST', $writer);`. Bind this to Laravel’s service container if reused across requests.
- Will this break existing JSON/XML serialization in Kiota clients?
- No, this package only affects `text/plain` content types. Kiota’s default serializers (e.g., JSON) remain unchanged. You can mix this serializer with others in the same client by configuring `RequestInformation` per endpoint.
- Is this package suitable for parsing CSV or legacy plain-text APIs in Laravel?
- Yes, if you’re using Kiota-generated clients. This serializer converts raw `text/plain` responses (e.g., CSV, logs, or legacy systems) into structured PHP objects. For non-Kiota APIs, you’d need a separate parser like `league/csv` or custom logic.
- Are there performance concerns with plain-text serialization vs. JSON?
- Plain-text parsing (e.g., CSV, logs) is generally slower than JSON due to lack of schema validation. Benchmark your use case—Kiota’s text serializer adds minimal overhead, but large payloads may require optimization (e.g., streaming). JSON remains faster for structured data.
- Can I use this with Microsoft Graph API in Laravel?
- Absolutely, if you’re using Kiota-generated Microsoft Graph clients. This package enables handling `text/plain` responses (e.g., for certain Graph endpoints or custom APIs). Install it alongside `microsoft/kiota-php` and configure the serializer as needed.
- What happens if the API returns malformed plain text? Does it throw exceptions?
- Yes, the serializer validates input and throws exceptions for malformed text (e.g., invalid encoding, truncated data). Handle these in your Laravel exception handler or middleware. Test edge cases like empty strings or non-UTF-8 text.
- Are there alternatives to this package for plain-text APIs in Laravel?
- If you’re *not* using Kiota, alternatives include custom Guzzle middleware, `league/csv`, or `symfony/serializer`. For Kiota users, this is the official Microsoft-maintained solution. Avoid reinventing the wheel unless you need Kiota-agnostic flexibility.
- How do I test this serializer in a Laravel project?
- Mock Kiota’s `RequestInformation` in PHPUnit tests, inject the `TextSerializationWriter`, and verify serialization/deserialization. Test edge cases like empty strings, special characters, and encoding (e.g., ISO-8859-1). Use Laravel’s HTTP tests to simulate API responses.