Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Kiota Serialization Json Laravel Package

microsoft/kiota-serialization-json

JSON serialization library for PHP from Microsoft's Kiota toolchain. Lets Kiota-generated API clients parse and serialize JSON payloads. Install via Composer with microsoft/kiota-serialization-json.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. This is not a general-purpose JSON encoder. It is a pluggable implementation of the microsoft/kiota-abstractions serialization contracts (ParseNode / SerializationWriter factories) that a Kiota-generated PHP client consumes to turn HTTP payloads into typed models. It has value only in conjunction with (a) code generated by the Kiota CLI from an OpenAPI description and (b) a Kiota HTTP request adapter (Guzzle-based) plus an authentication provider. In a Laravel codebase that means it sits at the boundary layer of an outbound API integration, not in the domain or persistence layer. If we are not generating a client with Kiota, this package has no role — Laravel's Http client, JsonResource, or Saloon already cover the same ground with far better ergonomics.

Integration feasibility. Mechanically trivial: composer require microsoft/kiota-serialization-json and it slots in as a constructor argument to the generated client. The real cost is upstream: toolchain install (Kiota CLI, .NET runtime or containerised invocation), OpenAPI source curation, generation, and versioning of generated code. The Dependents: 0 figure and 8 stars are misleading as risk signals — this is a release-only mirror of a subpackage in the microsoft/kiota-php monorepo, so its consumers are generated clients rather than libraries that declare it as a dependency. But they do accurately signal low community mindshare: expect almost no Stack Overflow or blog coverage, and debugging paths that terminate in a read-only mirror repo.

Technical risk.

  • Hard PHP floor. v2.0.0 dropped PHP 7.2–8.1 to address security issues; minimum is now PHP 8.2. Any Laravel estate still on 8.0/8.1 either cannot upgrade or is frozen on the 1.x line, which will not receive fixes.
  • Synchronised versioning. As of 1.5.0, all Kiota PHP libraries version-bump together. A patch to this package can force coordinated bumps of abstractions, the HTTP adapter, and the generated client — a wider blast radius than a normal composer update.
  • Serialization correctness surface. The changelog shows a history of edge-case fixes in exactly the areas that bite in production: DateTime handling, negative date periods, binary/stream writing, addcslashes escaping, float-from-integer coercion, composed (intersection/union) types, and null handling in collections. That is a mature-but-actively-churning correctness surface; regression risk on upgrade is real.
  • Read-only distribution. Issues and PRs must go to kiota-php, not this repo. Any fix we need is upstream-gated with no commercial SLA.
  • Version coupling to the generator. Generated code and the serialization/runtime libraries must stay in compatible majors; there is no independent upgrade cadence.

Key questions. Which specific API are we integrating (Microsoft Graph is the canonical answer, and it has its own PHP SDK that may make raw Kiota redundant)? Is the target API's OpenAPI description stable and Microsoft-blessed, or internal and likely to drift? Does our PHP runtime baseline support 8.2+ everywhere we would deploy? Who owns regenerating the client when the API changes? Is the team prepared to treat generated code as vendored, non-editable artefact?

Integration Approach

Stack fit. Poor-to-neutral as a Laravel-native choice, good as a boundary adapter. Laravel already ships Guzzle via Illuminate\Support\Facades\Http, so the Guzzle 8 support added in 2.2.0 avoids a dependency conflict — but the Kiota client will not use Laravel's HTTP client, so we lose Http::fake() test ergonomics, Laravel's retry/backoff helpers, and the event hooks. Authentication is entirely outside this package: an access-token provider and request adapter must be wired and refreshed manually, meaning we re-implement token caching that Laravel packages normally give us for free. Treat this package as infrastructure behind a hand-written repository/gateway class, never leaking ParseNode types into controllers, jobs, or Blade/Inertia payloads.

Migration path. Greenfield or additive only. There is no sane path from existing hand-rolled Guzzle/Saloon integrations to Kiota unless we are also adopting code generation wholesale — the win is eliminating hand-maintained DTO mapping for a large, fast-moving API surface, and that win only materialises at scale (hundreds of endpoints, frequent schema changes). For a handful of endpoints, this is a net negative.

Compatibility. Requires PHP ≥ 8.2, which aligns with Laravel 11/12. Check transitive constraints against our pinned Guzzle major (7 vs 8) and our microsoft/kiota-abstractions version. Because of synchronised versioning, pin exact versions in composer.json for the whole Kiota set (abstractions, serialization, HTTP adapter) and upgrade them as a single unit — never let Dependabot bump one in isolation.

Sequencing.

  1. Confirm the API has an authoritative OpenAPI description and that Graph's official PHP SDK is not the simpler answer.
  2. Install Kiota CLI in CI/dev containers; commit the generation command and the source spec to the repo.
  3. Generate into a dedicated namespace (e.g. App\Generated\...) that is excluded from PHPStan/PSALM baselines and from code-review style rules.
  4. Add kiota-serialization-json, kiota-abstractions, and the Guzzle HTTP adapter as an explicitly pinned set.
  5. Implement auth provider + token cache behind a Laravel service provider; register the client as a singleton.
  6. Write a thin gateway interface returning our own DTOs, with contract tests using recorded fixtures (Http::fake will not intercept the Kiota client — use the adapter's own mocking layer or a fake request adapter).
  7. Only then build features; keep the generated layer swappable.

Operational Impact

Maintenance. Low code volume, non-trivial upgrade discipline. The mirror repo means we are a consumer of a monorepo release train, and the breaking 2.0.0 PHP-floor change is a preview of how these arrive: bundled with security justification, no deprecation runway. Budget for a recurring quarterly review of the Kiota set as a single upgrade ticket, plus a regeneration step whenever the upstream spec changes. Abandonment risk is low given Microsoft ownership, but attention risk is high (8 stars means our issue is competing with Graph SDK issues for maintainer time).

Support. No vendor SLA. Escalation is GitHub issues on kiota-php and reading the Kiota core docs. Mitigation: keep the generated surface behind our own interfaces so a fallback to hand-written Guzzle/Saloon is a contained rewrite rather than an archaeology project. Maintain at least one engineer with Kiota familiarity — this is a single-point-of-failure skills profile.

Scaling. The package itself is stateless and CPU-bound; it scales horizontally with the PHP workers and adds no I/O, no connection pool, no cache. The scaling concern is memory and allocation on large collections — 2.0.1 specifically reduced parse node allocations for primitive deserialization, so we are on the right side of that curve, but very large JSON responses should still be streamed or paginated at the API layer rather than fully materialised. Under Octane, ensure the generated client and serialization factories are resolved per-request or are genuinely stateless, and that token caches are shared (Redis) rather than per-worker.

Failure modes.

  • Silent schema drift — upstream API changes shape, generated models deserialize with nulls instead of throwing. Needs contract tests and response validation, not just happy-path fakes.
  • Coercion/escaping regressions — the changelog's history of DateTime, negative period, escaping and float/int fixes means subtle data corruption is a plausible failure class. Golden-file serialization tests are the control.
  • Version mismatch — an isolated Dependabot bump of the serialization package against a stale adapter produces hard-to-diagnose runtime errors. Enforce grouped, pinned upgrades in CI.
  • Auth expiry / no retry — because the request adapter sits outside Laravel's HTTP client, we lose built-in retry and token-refresh behaviour; a 401 storm is an operational risk until we implement it explicitly.
  • Blocked PHP upgrades — the 8.2 floor cuts both ways: it forced a major bump, and it will force another when 8.3/8.4 minimums land.

Ramp-up. Steep for the unfamiliar, and mostly front-loaded into concepts rather than code: OpenAPI-derived models, ParseNode navigation, composed types, request adapters, and the Kiota CLI itself. Generated code is verbose and unfriendly to read, which slows onboarding and code review unless the team agrees the generated namespace is untouchable. Estimate roughly one to two weeks before a mid-level Laravel developer is productive, contingent on a clear gateway abstraction and a written regeneration runbook. Without those two artefacts, the ramp-up cost recurs on every API change.

TPM recommendation. Score and adoption signals suggest a niche, low-mindshare, single-purpose dependency. Adopt only if we are integrating a large, spec-described API — realistically Microsoft Graph — where codegen removes meaningful toil. For ordinary third-party REST integration in Laravel, the opportunity cost is negative and this package should be declined in favour of the framework's own HTTP client.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin