microsoft/kiota-serialization-text
Text/plain serialization/deserialization library for PHP projects generated with Microsoft Kiota. Adds support for handling plain text request/response bodies as a Kiota serialization implementation; install via composer (microsoft/kiota-serialization-text).
text/plain content, designed to integrate seamlessly with Kiota-generated PHP clients (e.g., Microsoft Graph SDKs). If the Laravel application interacts with APIs via Kiota-generated clients (e.g., for Microsoft 365, Azure, or other Kiota-supported services), this package provides a standardized, type-safe way to handle plain-text serialization/deserialization.text/plain payloads. This is ideal for APIs where raw text (e.g., CSV, plain-text responses, or legacy systems) must be parsed into structured objects.HttpClient, Guzzle) doesn’t natively support Kiota’s serialization model, this package is only relevant if Kiota is already in use (e.g., for Microsoft APIs). For vanilla Laravel APIs, this offers no direct benefit.microsoft/kiota-php). If the Laravel app isn’t using Kiota, integration is not feasible without rewriting API clients to adopt Kiota’s architecture.microsoft/kiota-serialization-text).RequestInformation or SerializationWriter to use this serializer for text/plain content types.use Microsoft\Kiota\Serialization\Text\TextSerializationWriter;
$writer = new TextSerializationWriter();
$requestInfo = new RequestInformation(
new Uri("https://example.com/api"),
"POST",
new TextSerializationWriter()
);
text/plain serialization in Kiota contexts. For JSON/XML APIs, this is irrelevant.text/plain serialization? Are these Microsoft APIs (e.g., Graph), or are they custom?text/plain content? Kiota’s default serializers may still be needed.text/plain responses must be deserialized into objects.kiota generate).composer require microsoft/kiota-serialization-text.RequestInformation to use TextSerializationWriter for relevant endpoints.// In a service or controller
$client = new GraphClient();
$client->setRequestAdapter(new KiotaRequestAdapter(
new TextSerializationWriter() // Override for text/plain
));
AppServiceProvider:
$this->app->bind(KiotaClient::class, function ($app) {
return new GraphClient(new TextSerializationWriter());
});
^2.0.2 as of the last release). Check composer.json for constraints.guzzlehttp/psr7) must align with Laravel’s ecosystem.text/plain serialization/deserialization for critical endpoints.TextSerializationWriter doesn’t meet needs (e.g., custom delimiters, encoding), extensions may be required.tap() can help inspect objects.explode()/trim() for plain text).text/plain responses may increase memory usage. Test with memory profiling tools (e.g., Blackfire).| Failure Scenario | Impact | Mitigation |
|---|---|---|
Malformed text/plain response |
Deserialization errors | Validate input with filter_var() or regex. |
| Kiota version mismatch | Serializer incompatibility | Pin versions in composer.json. |
| Network timeouts with large text | API timeouts | Implement retry logic (e.g., Guzzle middleware). |
| Missing Kiota dependency | Runtime errors | Use composer require with strict versioning. |
| Laravel/Kiota DI conflicts | Unresolvable dependencies | Explicitly bind Kiota clients in Laravel’s container. |
RequestInformation, SerializationWriter).How can I help you explore Laravel packages today?