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

Jsonrpc Server Sdk Laravel Package

yoanm/jsonrpc-server-sdk

A framework-agnostic PHP SDK for building JSON-RPC 2.0 servers: define methods, dispatch requests and notifications to handlers, and return spec-compliant responses, with middleware and flexible configuration for integrating the protocol into your app.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. The SDK is deliberately transport-agnostic: its public surface is essentially handleRequest(string $jsonRpcRequest): string. That is a genuinely good architectural fit for Laravel, because it refuses to own HTTP. Laravel keeps routing, middleware, auth, rate limiting, and logging; the SDK owns only JSON-RPC 2.0 envelope handling (parse, dispatch, error-code shaping, batch/notification semantics). There is no framework lock-in and no global state to fight with Octane.

The trade-off is that the package ships as a library, not a framework integration. There is no service provider, no facade, no publishable config, no container-aware method resolution. The maintainer publishes a Symfony bundle (yoanm/jsonrpc-server-symfony-bundle) that supplies exactly this glue; for Laravel you rebuild roughly 100–200 lines of it yourself. That is the central TPM conclusion: low technical risk, but the integration work is yours and must be treated as owned code.

Integration feasibility. Feasible. A senior Laravel engineer can prove the happy path (two methods, success + error + batch) in a 1–2 day spike, and reach production hardening in one sprint. The concrete gaps to close:

  • Container-aware method registry — SDK methods are plain callables/classes; you need a registry that resolves them from Laravel's container so constructor injection of services works.
  • Parameter validation — the SDK's error taxonomy expects structured invalid params responses; bridging to Laravel's Validator is manual.
  • Batch amplification guard — no built-in max batch size, so a single request can fan out to N method invocations.
  • Exception mapping — uncaught exceptions inside a method must become JSON-RPC internal error objects, not Laravel 500 pages.
  • No OpenRPC/OpenAPI schema generation without pulling in additional YoanM packages.

Technical risk. Code risk is low: MIT, PSR-3 logging hooks, a narrow and well-tested domain, an actively maintained release (2025-12-13). Vendor risk is the real exposure: 5 stars, 0 dependents, a single maintainer, and effectively no community answer base. That is a bus-factor problem, not a correctness problem. Mitigate by isolating the SDK behind a thin internal adapter interface so a swap to sajya/server (the Laravel-native alternative) or a hand-rolled ~200-line dispatcher is a contained change rather than a rewrite.

Key questions.

  1. What are the symfony/* version constraints (options-resolver, config, validator) and do they resolve cleanly against Laravel 11/12's Symfony 7 set?
  2. Does it normalize positional vs. named params per spec, or does the method implementer receive only one shape?
  3. Are batch requests and notifications (no id, no response) handled natively, and does batch preserve per-call error isolation?
  4. What is the exception-to-error-code contract — are there typed exceptions, or is it a single JsonRpcException with a numeric code?
  5. Minimum PHP version and static-analysis/coverage posture?
  6. Release cadence and maintainer count — is this a hobby project or an actively supported SDK suite?
  7. Is the server object safe to hold as a container singleton under Laravel Octane (no per-request mutable state)?

Integration Approach

Stack fit. Laravel 10–12 on PHP 8.2+. The SDK's PSR-3 logger dependency binds cleanly to Laravel's Psr\Log\LoggerInterface; no queue, cache, or database coupling. It is stateless per request, which means it behaves identically under PHP-FPM and Octane, provided the server instance is built once and treated as immutable.

Migration path. Purely additive. Stand up a dedicated POST /rpc endpoint alongside existing REST routes — there is no reason to migrate existing consumers. Use namespaced method names (v1.user.get, v1.order.create) to get versioning for free, since JSON-RPC has no URL-based versioning. If replacing an existing RPC system, method names map 1:1 through the config registry, which makes a traffic-shadow cutover straightforward.

Compatibility. Several Laravel defaults actively work against JSON-RPC semantics and must be neutralized:

  • Laravel's exception handler converts failures to HTTP 4xx/5xx. JSON-RPC expects HTTP 200 with an error object in the body. Catch at the controller boundary and format deliberately.
  • Consume $request->getContent() (raw string), never $request->json() — the SDK wants the unparsed payload, and double-decoding breaks batch and notification handling.
  • Keep the route out of the CSRF-protected web group; use routes/api.php (or an explicit withoutMiddleware).
  • Accept application/json and application/json-rpc content types explicitly; Laravel's TrimStrings/ConvertEmptyStringsToNull middleware only touch input arrays, so the raw body is safe.
  • Publish an internal config map (config/jsonrpc.php) of method name → handler class, and bind it in a dedicated JsonRpcServiceProvider.

Sequencing.

  1. Spike (1–2 days): install, resolve Symfony constraint conflicts, prove success/error/batch/notification round-trips through a bare controller. Kill criterion: unresolvable dependency conflict with the target Laravel version.
  2. Adapter layer: JsonRpcController (single action), JsonRpcMethodRegistry, JsonRpcServiceProvider, config/jsonrpc.php. Everything framework-facing lives here, nothing else in the app imports SDK classes directly.
  3. Correctness: exception→error-code mapping, validator bridge, feature tests asserting the exact JSON-RPC envelope for every error code plus batch partial failure.
  4. Hardening: max batch size, throttle middleware, per-method timeouts, structured request logging with method name and duration.
  5. Rollout: ship behind a feature flag to one internal consumer first; widen after a week of clean error-rate data.

Operational Impact

Maintenance. Low churn expected, but the adapter layer is now your code and needs an owner. Pin to minor versions, enable automated dependency updates, and budget roughly 2–3 engineer-days per quarter for upgrades and Symfony/Laravel compatibility checks. The adapter boundary is the insurance policy: if the package stalls, replacement is a contained week, not a quarter.

Support. No commercial support, GitHub issues only, negligible community. Internal ownership is mandatory — there is no Stack Overflow safety net for edge cases. Compensate with above-average test coverage on the JSON-RPC envelope behaviors (batch, notification, parse error, invalid params), which are exactly the cases that will otherwise surface in production.

Scaling. Effectively free. Parsing and dispatch are microseconds of CPU; the endpoint is stateless and horizontally scales with the rest of the fleet. Two real considerations: batch amplification (one HTTP request → N method executions) needs an explicit cap and should be excluded from any "cheap" rate-limit tier; and per-method cost variance means a single expensive method can dominate capacity, so per-method metrics are required rather than aggregate endpoint latency.

Failure modes.

  • Malformed JSON → SDK returns a parse-error object; verify it does not escape as a Laravel 500.
  • Unknown method → method not found, but the response shape must be validated so clients don't see a framework error page.
  • Uncaught exception in a method → must map to internal error with no stack trace leakage, independent of APP_DEBUG.
  • Batch partial failure → one bad call must not poison the array; test explicitly.
  • Notification handling → empty-body 204/200 responses are easy to get wrong and will confuse naive clients.
  • Observability blind spot → JSON-RPC error responses carry HTTP 200, so APM dashboards and alerting will under-report failures unless errors are counted from the response body or from structured logs.
  • Vendor abandonment → silent, but recoverable via the adapter layer.

Ramp-up. One day for a senior Laravel engineer to be productive on the happy path; two to three days to internalize batch/notification semantics, the error-code contract, and the middleware interactions. Documentation is README-grade — accurate but example-light, with no Laravel-specific guidance. Given the tiny community, plan for a small internal design note (endpoint contract, method registry convention, error taxonomy) so the second engineer doesn't have to reverse-engineer the SDK.

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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib