stubbedev/laravel-stoli
A Laravel package by stubbedev that integrates Stoli into your application, providing a service provider, configuration options, and a straightforward Composer-based setup so you can add Stoli functionality to Laravel projects with minimal effort. It follows standard Laravel conventions.
Architecture fit. This is a build-time codegen tool, not a runtime dependency — it sits in the seam between a Laravel JSON API and a TypeScript client. The core architectural bet is "one definition per route file" (<Module>Routes), with createRoute(), RouteService, the routers, and the URL functions all reading from that single definition. That is the right shape if the problem you actually have is API contract drift between backend and frontend. It is a poor fit if the frontend is Blade/Inertia, if the API is consumed by non-TypeScript clients (mobile, partners), or if the team has not adopted spatie/laravel-data — the release hard-requires Data v4.
Integration feasibility. Tractable but constrained. The effective platform floor is PHP 8.2+, Laravel 12/13, Node 20–24, TypeScript 5.8+, plus spatie/laravel-data 4. That excludes Laravel 10/11 estates entirely — for those, this release is not adoptable without a platform upgrade first. The tested matrix (PHP 8.2–8.5 × Laravel 12/13 × Node 20–24) is unusually broad for a 1.0 and materially lowers integration risk. Integration points are well-defined: typescript:transform (including --watch), or standalone stoli:generate, with --check available as a CI gate.
Technical risk. Moderate, concentrated in the 0.x → 1.0 break rather than in the feature set:
stoli.js/stoli.d.ts → stoli.ts, with old files removed on next run. Any manual import of the old paths breaks, and committed artifacts linger in VCS history.StoreUserDataInput), not its Data type. Call sites typed against the Data type will fail — or, worse, pass structurally while masking validation-shape differences.createURLWithoutQuery() → resolve() is a behavior change, not a rename: leftover parameters are returned rather than deleted. Callers relying on deletion can silently leak params into query strings.unknown instead of Record<string, unknown> for unresolvable responses is safer but forces narrowing at every affected call site.<Module>Routes definitions. Routes registered via closures, vendor packages, or ad-hoc Route:: calls fall outside the source of truth and degrade to unknown.--check is only as strong as its adoption — nothing enforces it unless CI does.Key questions.
resolve() changes?'axios' => true vs 'client' => 'axios'?Route::resource, or inside vendor packages handled?php artisan route:cache?resolve() handle array/nested/repeated query parameters predictably?Stack fit. Strong fit for Laravel 12/13 + spatie/laravel-data 4 + a TypeScript SPA/consumer. Preferable to hand-maintained API clients or an OpenAPI-plus-codegen chain if the team is already Data-object-centric — in that case the route definition is the only new artifact. If the team's source of truth is currently an OpenAPI spec, this introduces a second one.
Migration path (sequenced).
stoli.js/stoli.d.ts removal — delete from VCS and from every import.stoli.ts.tsc --noEmit to enumerate call sites affected by the input-type change; fix StoreUserData* → StoreUserDataInput in request parameter positions.createURLWithoutQuery() → resolve(). Each call site needs a decision about the returned leftovers.'client' => 'fetch'|'axios' explicitly; retain 'axios' => true only if needed and track its removal.unknown responses at the call sites — this is where latent contract bugs surface; treat each as a real finding, not a type chore.stoli:generate --check into CI before merging the migration branch, so drift can't re-enter.'transform' => false question. Co-running inside typescript:transform (the default) means one pipeline and one ordering constraint; separating them means two things to keep in sync.Compatibility. Hard floors: PHP 8.2, Laravel 12, Node 20, TypeScript 5.8, Data 4. Any unmet floor converts this from a dependency bump into a platform program.
Maintenance. 1.0 signals semver intent, so future breaks should be major-version events — a meaningful improvement over 0.x. But the surface is wide (route definitions, two routers, URL functions, the generator, transformer integration), and each is a place where a Laravel or Data upgrade can change generated output. Expect regeneration churn on Laravel minors and budget review time for the resulting diffs.
Support. The single largest external risk is the Data v4 dependency; a Data 5 would likely force a Stoli major. Coverage of PHP 8.5, Laravel 13, and Node 24 in the test matrix is a strong liveness signal, but confirm release cadence and issue-response history before committing a roadmap to it.
Scaling. Codegen scales with route count, not traffic — so the concerns are developer-facing: --watch performance on large route sets, TypeScript server responsiveness if everything lands in one stoli.ts, and bundle size. 'urls' => true tree-shakeable URL functions help only if the bundler is actually configured to shake them.
Failure modes.
--check gating merges, non-negotiable.unknown; a team that reflexively casts reacquires the risk it just paid to remove.stoli.js/stoli.d.ts still imported somewhere; builds pass locally, break after cleanup.<Module>Routes definition is invisible, reintroducing exactly the drift the package exists to eliminate.resolve() returning leftovers — dropped params or stray query strings.Ramp-up. Moderate. Contributors must hold three things at once: Laravel route/Data/FormRequest conventions, the <Module>Routes definition idiom, and the shape of the generated output. The two most common early mistakes will be the input-vs-Data distinction and unknown narrowing. Recommend a short internal guide covering the route-definition pattern and an explicit "regenerate, never hand-edit" rule, plus a named owner for the generated files.
TPM recommendation. Adopt on new Laravel 12+ projects with a TypeScript frontend. For existing 0.x users, treat the upgrade as a scoped, scheduled piece of work with the Data v4 bump landed first and --check enforced in CI before the migration merges. Do not attempt this as a drop-in on Laravel ≤ 11.
How can I help you explore Laravel packages today?